The Binomial Distribution#
Suppose that we are dealing with an experiment with two outcomes 0 (faillure) and 1 (success) and that the probability of success is \(\theta\). We are interested in the random variable \(X\) tha counts the number of successful experiments in \(n\) trials. This variable is called a Binomial random variable. We write:
It can be shown (but beyond the scope of this class), that the probability of \(k\) successful experiments is given by the PMF:
where \({n\choose{k}}\) is the number of \(k\) combinations out of \(n\) elements, i.e.:
Here is how to define the binomial in scipy.stats:
n = 5 # Performing the experiment n times
theta = 0.6 # Probability of sucess each time
X = st.binom(n, theta) # Number of successes
Here are some samples:
X.rvs(10)
array([3, 3, 4, 4, 2, 3, 3, 2, 2, 4])
Let’s draw the PMF:
fig, ax = make_full_width_fig()
xs = range(n + 1)
ax.vlines(xs, 0, X.pmf(xs))
ax.set_xlabel('$x$')
ax.set_ylabel('$p(x)$')
save_for_book(fig, 'ch9.fig3')
Questions#
Start increasing the number of trials \(n\). Gradually take it up to \(n=100\). How does the resulting pmf look like? This starts to look like a bell curve. And indeed it is! We will learn more about this in Lecture 11: Expectations, variances, and their properties.