I have a list of numbers, and would like to sample from that list. The sampling however is based on some distribution which is specified by a user. I am not sure if alias method (here) using weights is the right one; my limited knowledge says alias method uses uniform distribution alone (correct me on that please!). What if I need to specify something like sample using log-normal as the underlying distribution or poisson for that matter? How do I do this kind of sampling?
A related question, if my list is say [1, 2, 3, 4, 5] and mean is 3, how do I get the sampling?
Have you tried np.random.choice
b = np.random.choice(a=[1,2,3,4,5], p=[0.2, 0.2, 0.2, 0.2, 0.2])
b is randomly sampled from a based on the distribution p
You can also use poisson
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With