in reply to Weighted random numbers generator

There's probably a CPAN module that does it. But there's also some interesting code in a column I wrote in 1996. Check it out.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.


update: Ahh yes, and that same code (or similar code) was used in my "spew" program.
  • Comment on •Re: Weighted random numbers generator

Replies are listed 'Best First'.
Re: Weighted random numbers generator
by crenz (Priest) on Mar 13, 2003 at 18:32 UTC

    There's probably a CPAN module that does it.

    I have a similar problem and already searched CPAN, but couldn't find anything. Any ideas how such an algorithm might be called?

      I'm not sure the algorithm would have a special name.

      It's just a name to generate "weighted uniform" distribution.
      I hope that the nodes in this thread helped you accomplish what you want - there is the initial solution and many improvements and ideas.