url = 'http://www.census.gov/genealogy/www/data/1990surnames/dist.male.first'
response = urllib.request.urlopen(url)
names, cumprobs = [], []
for line in response:
    name, prob, cumprob, rank = line.split()
cumprob = float(cumprob)
names.append(name)
cumprobs.append(cumprob)
cumprobs = [(p / cumprobs[-1]) for p in cumprobs]
N = 1000
selected = [names[bisect.bisect(cumprobs, random.random())] for i in range(N)]
print('\n'.join(selected))
Выбор элементов из списка python на основе вероятности