I needed to write a weighted version of random.choice (each element in the list has a different probability for being selected). This is what I came up with:
import numpy as np w=np.array([ 0.4, 0.8, 1.6, 0.8, 0.4]) np.random.choice(w, p=w/sum(w))