naming a data structure for weighted random selection without replacement

A while ago I wrote a little data structure that allows weighted random selection-without-replacement from a collection of values in O(log n) time.[1] I'm now in the process of packaging it up for Hackage, but I'm looking for good names for both the type and its operations. The name I have at the moment is "Pool", which I'm reasonably happy with, but I wanted to see if I could find anything better. Asking on #haskell got me a few responses: * Hat (cute, but conflicts with the program tracer) * Bag (already way too overloaded) * Bucket (not as suggestive as Pool) I have three main operations: * "pull" selects a random element, returning it and the remainder, but fails if the pool is empty * "pullN" selects /n/ distinct elements, returning them and the remainder, but fails if the pool has too few elements * "takeN" selects up to /n/ distinct elements, returning them and the remainder, but returns no more elements than could be found in the pool (analogous to Data.List.take) Any suggestions? Stuart [1] Actually I delegated most of the work to the data-structure-in-a-can that is Data.FingerTree, but that's another story.

On Mon, 18 Feb 2008, Stuart Cook wrote:
A while ago I wrote a little data structure that allows weighted random selection-without-replacement from a collection of values in O(log n) time.[1] I'm now in the process of packaging it up for Hackage, but I'm looking for good names for both the type and its operations.
Some ours ago I uploaded a package which would allow this: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/probability-0.2 You would stack a State transformer with a distribution as state and the inner monad is a Probability.Random.T. A similar example is here: http://darcs.haskell.org/probability/src/Numeric/Probability/Example/Collect... But maybe your concern is efficiency, and thus you need the special data structure.

On Feb 18, 2008 5:11 AM, Stuart Cook
A while ago I wrote a little data structure that allows weighted random selection-without-replacement from a collection of values in O(log n) time.[1] I'm now in the process of packaging it up for Hackage, but I'm looking for good names for both the type and its operations.
I'm pretty sure it should have Random in the name whatever it is called. Luke
The name I have at the moment is "Pool", which I'm reasonably happy with, but I wanted to see if I could find anything better. Asking on #haskell got me a few responses:
* Hat (cute, but conflicts with the program tracer) * Bag (already way too overloaded) * Bucket (not as suggestive as Pool)
I have three main operations:
* "pull" selects a random element, returning it and the remainder, but fails if the pool is empty * "pullN" selects /n/ distinct elements, returning them and the remainder, but fails if the pool has too few elements * "takeN" selects up to /n/ distinct elements, returning them and the remainder, but returns no more elements than could be found in the pool (analogous to Data.List.take)
Any suggestions?
Stuart
[1] Actually I delegated most of the work to the data-structure-in-a-can that is Data.FingerTree, but that's another story. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Mon, 2008-02-18 at 11:37 +0000, Luke Palmer wrote:
On Feb 18, 2008 5:11 AM, Stuart Cook
wrote: A while ago I wrote a little data structure that allows weighted random selection-without-replacement from a collection of values in O(log n) time.[1] I'm now in the process of packaging it up for Hackage, but I'm looking for good names for both the type and its operations.
I'm pretty sure it should have Random in the name whatever it is called.
Obvious idea: How about WeightedRandom? Michał

Michał Pałka wrote:
On Mon, 2008-02-18 at 11:37 +0000, Luke Palmer wrote:
On Feb 18, 2008 5:11 AM, Stuart Cook
wrote: A while ago I wrote a little data structure that allows weighted random selection-without-replacement from a collection of values in O(log n) time.[1] I'm now in the process of packaging it up for Hackage, but I'm looking for good names for both the type and its operations. I'm pretty sure it should have Random in the name whatever it is called.
Obvious idea: How about WeightedRandom?
the "without replacement" thing is more specific. Although maybe the design could accomodate selection-with-replacement in the same package too or RandomPool? RandomHat? OutOfAHat? :-) -Isaac

On Tue, Feb 19, 2008 at 1:27 PM, Isaac Dupree
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

Stuart Cook
The name I have at the moment is "Pool", which I'm reasonably happy with, but I wanted to see if I could find anything better. Asking on #haskell got me a few responses:
...
Any suggestions?
How about Tombola? Brett
participants (6)
-
Brett Gibson
-
Henning Thielemann
-
Isaac Dupree
-
Luke Palmer
-
Michał Pałka
-
Stuart Cook