[Haskell-cafe] naming a data structure for weighted random selection without replacement

Stuart Cook scook0 at gmail.com
Mon Feb 18 22:31:21 EST 2008


On Tue, Feb 19, 2008 at 1:27 PM, Isaac Dupree <isaacdupree at charter.net> wrote:
>  the "without replacement" thing is more specific. Although maybe the
>  design could accomodate selection-with-replacement in the same package too

Once you have without-replacement, with-replacement is easy: just
re-use the old structure instead of the new one. Laziness means that
you don't even pay the cost of deletion.

(Multiple-with-replacement takes a little more work, because you can't
just re-use the multiple-without-replacement function if you want each
draw to be independent.)


>  or RandomPool? RandomHat? OutOfAHat? :-)

I'm currently leaning towards something like
"Data.Random.WeightedPool". (I really love Hat and Urn, but I now
think they're a little *too* cute.)


Stuart


More information about the Haskell-Cafe mailing list