Good grief, that's a terrible subject header. I have no idea how else to
summarize this, though. The point of this post is to solicit alternative
methods for what I'm doing.
Let's say I want to randomly generate items in given proportions. For
example:
dogs: 400
cats: 200
pigeons: 0
frogs: 0
ducks: 100
"Select" is out. This needs to work for lists of arbitrary length. What
follows is seminal (ignoring the list items themselves), just to show how
I'm approaching this.
I enter 400,200,10,0,100 when prompted:
| arrOne = Split(InputBox("Enter data points"),",")
| redim arrTwo(UBound(arrOne),3)
| Randomize
|
| total = 0
| For j = 0 To UBound(arrOne)
| arrTwo(j,0) = arrOne(j)
| total = total + arrTwo(j,0)
| Next
|
| For i = 1 To total
| fud = 0
| test = Rnd()
| test2 = 0
| For j = 0 To UBound(arrTwo)
| arrTwo(j,1) = (arrTwo(j,0)+fud)/total
| fud = fud + arrTwo(j,0)
| If test > test2 And test < arrTwo(j,1) Then arrTwo(j,2) = arrTwo(j,2) + 1
| test2 = arrTwo(j,1)
| Next
| Next
|
| For i = 0 To UBound(arrTwo)
| WScript.Echo arrTwo(i,2)
| next
A typical result:
------
427
181
11
91
------
Note that the number of iterations just happens to be the total; what I'm
after isn't so much the number of items on completion, rather I'm after an
average rate that's proportionate as this thing runs.
Any other, simpler ways of doing this kind of thing?
--
Scott
Almost summer! http://snipurl.com/trebuchet