I am trying to write a program to select a random name from the US Census last name list. The list format is
Name Weight Cumulative line
-----
I've created a C# library for randomly selected weighted items.
Some example code:
IWeightedRandomizer randomizer = new DynamicWeightedRandomizer();
randomizer["Joe"] = 1;
randomizer["Ryan"] = 2;
randomizer["Jason"] = 2;
string name1 = randomizer.RandomWithReplacement();
//name1 has a 20% chance of being "Joe", 40% of "Ryan", 40% of "Jason"
string name2 = randomizer.RandomWithRemoval();
//Same as above, except whichever one was chosen has been removed from the list.