Python  1.0
Namespaces | Functions
weightedNumGenerator.py File Reference

Namespaces

 weightedNumGenerator
 Return random numbers weighted by given probabilities.
 

Functions

def weightedNumGenerator.genWeightedList (l, weights)
 Method 1 – given a list of of items and a list of probabilities, return a new list that contains int(100*prob[i]) duplicates of the i-th item. More...
 
def weightedNumGenerator.genWeightedListD (d)
 Using a dictionary, instead of two lists. More...
 
def weightedNumGenerator.weightedRand (seq)
 Return a random element from seq (same of choice from random). More...
 
def weightedNumGenerator.weightedRand2 (l, weights)
 Method 2 – given list of items and a list of probabilities, which sum up to one, for example, 0.5 + 0.2 + 0.2 + 0.1 = 1.0. More...
 
def weightedNumGenerator.weightedRandD (d)
 Using a dictionary. More...
 
def weightedNumGenerator.main ()
 Main program for testing. More...