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

Re: Random generation of items in given proportions by name

name
Thu Apr 29 02:48:53 CDT 2004

""Select" is out."


I share your dhtml exhaustion and grief.


==================

So ?

Even Ms has had better examples compared to what you posted.

A long time since.






"Scott Marquardt" <wasREMOVEket5@hotmail.com> wrote in message
news:wtcosfw0wzmg.dlg@marquardts.org...
> 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


Re: Random generation of items in given proportions by name

name
Thu Apr 29 02:57:44 CDT 2004

It may through you off.

Alternatively share your dream solution with
an implementation in /javascript/jscript

where the

"BOUNDS"

are less explicit.

============

For the record, that you can get anything done in the first place.








"Scott Marquardt" <wasREMOVEket5@hotmail.com> wrote in message
news:wtcosfw0wzmg.dlg@marquardts.org...
> 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


Re: Random generation of items in given proportions by Scott

Scott
Thu Apr 29 10:23:18 CDT 2004

name opined thusly on Apr 29:
> ""Select" is out."
>
> I share your dhtml exhaustion and grief.
>
> ==================
>
> So ?
>
> Even Ms has had better examples compared to what you posted.
>
> A long time since.

?!

Is it a bot?

- Scott

Re: Random generation of items in given proportions by Dr

Dr
Thu Apr 29 07:38:39 CDT 2004

JRS: In article <wtcosfw0wzmg.dlg@marquardts.org>, seen in news:microso
ft.public.scripting.vbscript, Scott Marquardt
<wasREMOVEket5@hotmail.com> posted at Wed, 28 Apr 2004 23:56:10 :
>
>Let's say I want to randomly generate items in given proportions. For
>example:
>
>dogs: 400
>cats: 200
>pigeons: 0
>frogs: 0
>ducks: 100

<URL:http://www.merlyn.demon.co.uk/pas-rand.htm#RandDist>, sub-head
Discrete, may help; see also Weighted Random, below that.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

Re: Random generation of items in given proportions by Scott

Scott
Thu Apr 29 12:50:54 CDT 2004

Dr John Stockton opined thusly on Apr 29:
> JRS: In article <wtcosfw0wzmg.dlg@marquardts.org>, seen in news:microso
> ft.public.scripting.vbscript, Scott Marquardt
> <wasREMOVEket5@hotmail.com> posted at Wed, 28 Apr 2004 23:56:10 :
>>
>>Let's say I want to randomly generate items in given proportions. For
>>example:
>>
>>dogs: 400
>>cats: 200
>>pigeons: 0
>>frogs: 0
>>ducks: 100
>
> <URL:http://www.merlyn.demon.co.uk/pas-rand.htm#RandDist>, sub-head
> Discrete, may help; see also Weighted Random, below that.

Very good indeed, thank you. I'd done some of this a long time ago
(producing a normal distribution), but this is a good page. Thanks.

--

Scott

Almost summer! http://snipurl.com/trebuchet

Re: Random generation of items in given proportions by Al

Al
Sun May 02 23:40:47 CDT 2004


"Scott Marquardt" <wasREMOVEket5@hotmail.com> wrote in message
news:qf4y3pd2obb5.dlg@marquardts.org...
> name opined thusly on Apr 29:
> > ""Select" is out."
> >
> > I share your dhtml exhaustion and grief.
> >
> > ==================
> >
> > So ?
> >
> > Even Ms has had better examples compared to what you posted.
> >
> > A long time since.
>
> ?!
>
> Is it a bot?

The jury is still out on that one ;-)

/Al