# Binomial Distribution 

##### Definition

Repeated Bernoulli trials, such as repeated coin tosses.

Urn Model: 1 urn with N balls (pN red and (1-p)N black). Probability to draw k red balls with n trials while putting the ball back after each trial.

Parameters
Notation \text{B}(n, p)
Support k \in \{0, 1, ..., n \}
Mean n \cdot p
Variance np(1-p)
PMF f(k, n, p) = \binom{n}{k} p^k (1-p)^{n-k}

## Probability Mass Function

f(k, n, p) = \mathop{P}( X = k ) = \binom{n}{k} p^k (1-p)^{n-k}

with the number of trials n, the number of successes k, and the success probability p.

import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as st

n = 30; p1 = 1/6.0; p2 = 0.5;

lx = np.arange(0,n+1)
plt.plot(lx, st.binom.pmf(lx, n, p1), label='n= 30, p= 1/6 ' )
plt.plot(lx, st.binom.pmf(lx, n, p2), label='n= 30, p= 1/2 ' )
plt.show()