In article <048601c2f5e4$b88d1ec0$0300a8c0 / austin.rr.com>,
Hal E. Fulton <hal9000 / hypermetrics.com> wrote:
>----- Original Message ----- 
>From: "Phil Tomson" <ptkwt / shell1.aracnet.com>
>Newsgroups: comp.lang.ruby
>To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
>Sent: Saturday, March 29, 2003 2:04 AM
>Subject: Re: Weighted random selection -- how would you do this?
>
>
>> >This should work, I think.
>> >
>> 
>> Hmmm.... Wouldn't this be biased by order?
>
>Elaborate, Phil... do you mean that the actual
>distribution would be wrong? Or just that there
>would be a pattern in the sequence of choices?
>

I tried running it a few times and well it seems to work.

I was just thinking that the order of the elements in the list could 
influence which is picked (for example if elements with high weights 
appeared earlier or later in the list), but it doesn't seem to be the 
case.  Certainly a lot more compact and faster than my RouletteWheel 
example.

Phil