random sample with weights python

Solutions on MaxInterview for random sample with weights python by the best coders in the world

showing results for - "random sample with weights python"
María Camila
07 May 2016
1import random
2
3random.choices(
4  population=[a, b, c, d],  # list to pick from
5  weights=[0.2, 0.2, 0.2, 0.4],  # weights of the population, in order
6  k=5  # amount of samples to draw
7)