I need to obtain a k-sized sample without replacement from a population, where each member of the population has a associated weight (W).
Numpy\'s rando
You can use np.random.choice with replace=False as follows:
np.random.choice
replace=False
np.random.choice(vec,size,replace=False, p=P)
where vec is your population and P is the weight vector.
vec
P
For example:
import numpy as np vec=[1,2,3] P=[0.5,0.2,0.3] np.random.choice(vec,size=2,replace=False, p=P)