How can I generate a size 10000 Numpy array of 1's and 0's where getting 1's is weighted by a chance of 0.11?
Asked
Active
Viewed 451 times
1 Answers
1
Use numpy's random choice.
from numpy.random import choice
ratio = 0.11
draw = choice([0,1], 10000, p=[1-ratio, ratio])
# Evaluate
sum(draw)
# 1119

Alex Metsai
- 1,837
- 5
- 12
- 24