I am working on a simple problem, I want to write a function that will randomly draw n samples of size q from a binomial distribution (say 60% 1, and 40% 0), and then save the share of 1s from each sample in an array (so that I can analyze that array later). For instance, I would like to simulate, if I drew 1,000 samples each of size 30 from a distribution with 60% 1s and 40% 0s, and I would like as an output an array of length 1,000, where each row represents the share of 1's from that sample.
To get the number of 1s, it will be
import numpy as np
sim = np.random.binomial(n=30,p=0.6,size=1000)
To actually get the draws:
sim = np.random.binomial(n=1,p=0.6,size=(1000,30))
sim.shape
import matplotlib.pyplot as plt
plt.hist(np.mean(sim,axis=1))