logo

The Mean and Variance of the Bernoulli Distribution 📂Probability Distribution

The Mean and Variance of the Bernoulli Distribution

Formula

Given XX \sim when Bin(1,p)\operatorname{Bin}(1, p), the mean and variance of XX are as follows.

E(X)=p E(X) = p

Var(X)=p(1p)=pq,q=1p \Var(X) = p(1-p) = pq, \qquad q = 1 - p

Proof

For p[0,1]p \in [0, 1], a discrete probability distribution with the following probability mass function is called a Bernoulli distribution.

f(x)=px(1p)1x,x=0,1 f(x) = p^{x}(1-p)^{1-x}, \qquad x = 0, 1

Direct Calculation

By the definition of expected value,

E(X)=x=0,1xf(x)=0f(0)+1f(1)=0(1p)+1p=p \begin{align*} E(X) &= \sum\limits_{x = 0, 1} x f(x) \\ &= 0 \cdot f(0) + 1 \cdot f(1) \\ &= 0 \cdot (1-p) + 1 \cdot p \\ &= p \end{align*}

To obtain the variance, let’s calculate E(X2)E(X^{2}).

E(X2)=x=0,1x2f(x)=02f(0)+12f(1)=02(1p)+12p=p \begin{align*} E(X^{2}) &= \sum\limits_{x = 0, 1} x^{2} f(x) \\ &= 0^{2} \cdot f(0) + 1^{2} \cdot f(1) \\ &= 0^{2} \cdot (1-p) + 1^{2} \cdot p \\ &= p \end{align*}

The variance is Var(X)=E(X2)E(X)2\Var(X) = E(X^{2}) - E(X)^{2}, thus

Var(X)=pp2=p(1p)=pq \Var(X) = p - p^{2} = p(1-p) = pq

From the Moment Generating Function

The moment generating function of the Bernoulli distribution is as follows.

m(t)=1p+pet=q+pet m(t) = 1 - p + pe^{t} = q + pe^{t}

The expected value is m(0)m^{\prime}(0), therefore

E(X)=m(0)=pett=0=p E(X) = m^{\prime}(0) = pe^{t}|_{t=0} = p

To find the variance, let’s calculate m(0)m^{\prime\prime}(0).

m(t)=pett=0=p m^{\prime\prime}(t) = p e^{t}|_{t=0} = p

Thus, the variance is Var(X)=m(0)m(0)2\Var(X) = m^{\prime\prime}(0) - m^{\prime}(0)^{2}, and consequently

Var(X)=pp2=p(1p)=pq \Var(X) = p - p^{2} = p(1-p) = pq