Given a list of tuples where each tuple consists of a probability and an item I\'d like to sample an item according to its probability. For example, give the list [ (.3, \'a\'),
Since nobody used the numpy.random.choice function, here's one that will generate what you need in a single, compact line:
numpy.random.choice(['a','b','c'], size = 20, p = [0.3,0.4,0.3])