Properties of the Bernoulli distribution

Although a Bernoulli distribution is extremely simple,

\[ p(x) = \begin {cases} \pi & \quad \text{if } x = 1\\[0.5em] (1 - \pi) & \quad \text{if } x = 0\\[0.5em] 0 & \quad \text{otherwise} \end {cases} \]

it is instructive to derive its mean and variance.

Bernoulli mean and variance

If a random variable \(X\) has a \(\BernoulliDistn(\pi)\) distribution, its mean and variance are

\[ E[X] = \pi \spaced{and} \Var(X) = \pi(1-\pi) \]
\[ E[X] \;=\; \sum_{\text{all } x} x\times p(x)\; =\; 1 \times \pi + 0 \times (1 - \pi) \;=\; \pi \]

To find the variance of \(X\), we first find the expected value of its square.

\[ E[X^2] \;=\; \sum_{\text{all } x} x^2\times p(x) \;=\; 1^2 \times \pi + 0^2 \times (1 - \pi) \;=\; \pi \]

From this,

\[ \Var(X) \;=\; E[X^2] - \left(E[X]\right)^2 \;=\; \pi - \pi^2 \;=\; \pi(1-\pi) \]