The motivation for writing this article is twofold. First is completeness, as the binomial distribution is an intuitive starting point for elegantly deriving the Poisson distribution which is a topic of a subsequent article, itself a key ingredient of another article. Second is showing how one can intuitively arrive at the binomial distribution as I run into people, from time to time, who have trouble understanding how exactly it works. While its very name might be intimidating to a beginner, it is based on a very simple and intuitive concept, as you'll see in a moment.
At its core, the binomial distribution is a discrete probability distribution which quantifies the likelihood that given $n$ trials, each with a binary outcome, $k$ of them will be a "success". The simplest example would be a series of coin flips, where the sides can be assigned to be either "success" or "failure".
Heads or tails?
Coins, cards, and dice are the usual suspects when it comes to illustrating concepts in probability theory as they're useful for building intuition. We’ll go with rolling dice just to mix it up a little. Now, here's a question: “If we roll three dice, one by one, what are the odds of getting two sixes?”
I'd like to use coins, but fair coin flips have an associated probability of $0.5$ which makes it equivalent to the probability of failure and thus might make it difficult for people to make some important observations, without introducing magic bias for illustration purposes. So, we stick to fair dice rolls by declaring a roll of six to be "success", "yes", $1$ or whatever you want to call it. Fair dice roll means that each face of the dice has a $1/6$ chance of coming up on top. In our case, the probability of success is thus $1/6$ while the probability of failure is a whopping $1 - 1/6 = 5/6$.
Given the probability of success is $1/6$ for each independent roll, only $1$ out of $6$ times is going to result in rolling a six. On that one out of six times, there's only a $1/6$ chance we roll another six, reducing the odds to $1$ out of $36$.
Why exactly do we multiply probabilities?
In my experience, this is where some folks get lost. They know the rule is to multiply probabilities in the case of independent events, but they don't know why. So, I will endeavor to elaborate further. There are six ways to roll the first dice. And six ways to roll the second one. For each of the six ways to roll the first dice, there are six ways we can roll the second one as they're independent of each other, one roll does not affect the outcome of the other. This brings us to a total of $36$ possibilities, each equally likely, yielding a probability of $1/36$.
On that $1$ out of $36$ times, there is a considerable chance we will not roll a six as the probability of failure is $5/6$. Thus, our chances decrease slightly to a final $5$ times out of $216$, giving us a roughly $2.3\%$ chance to roll two sixes followed by anything else. Two successes, one failure. Effectively, we computed the probability of a single arrangement of two successes and one failure with $p_s = 1/6$ as:
$$ p_sp_s(1 - p_s) = p_s^2(1 - p_s)^{3-2} = \left(\frac{1}{6}\right)^2 \frac{5}{6} = \frac{5}{216}$$
Notice there are three different ways of getting two successes and a failure, in this case, $\{SSF, SFS, FSS\}$. Our computation only deals with the probability of getting any one of those three possible orderings. Thus the probability of getting two successes and one failure is actually three times higher. To generalize this, let $n$ be the number of trials and $k$ be the number of successes, leaving failures implicitly quantified as $n-k$. We need to know how many ways we can order $k$ successes or $n-k$ failures in $n$ trials. Either will do, so we choose what is explicit, the number of successes. If there are $n$ trials, there is $n!$ ways they can be ordered. When you select the "temporal order" of the first trial, there remain only $n -1$ choices for the second placement and so forth. We're only choosing the placement of $k$ trials, the successes. Hence we need to stop the $n!$ factorial after $k$ "iterations", this is done by dividing it by $(n-k)!$ (write it out if you don't see it). Now we have all the ways we can order $k$ successes in the $n$ trial slots. We're only interested in the unique placements of successes (and thus failures which are implicitly in-between) and given that there are only binary outcomes, some of these unique conceptual orderings of trials will end up aliasing one another once their values are "substituted in", we need to remove those.
Let me show you what I mean. In our trivial example with $n=3$ and $k=2$, there is $3! = 6$ ways to order the trials. There is $3! / (3 - 2)! = 6$ ways to order $2$ successes in the $3$ trials. I will use numbers to indicate temporal ordering of the possible configurations: $\{12, 21, 13, 31, 23, 32 \}$. Notice that ordering successes as $12$ and $21$, $13$ and $31$, as well as $23$ and $32$ results in redundancy. Hence, there is only $3$ unique ways we need to account for. There is $k!$ ways to order $k$ elements, hence we finally divide by $k!$. This brings us to the final equation where $q$ is the probability of success, $k$ is the number of successes and $n$ is the total number of trials:
$$ p_q(k, n) = \frac{n!}{(n-k)!k!} q^k(1-q)^{n-k} = {n \choose k} q^k(1-q)^{n-k} $$
You might have recognized "n-choose-k" from combinatorics, ways of choosing $k$ successes out of $n$ trials which, while it matches the value, doesn't quite relay the semantics. And if you're wondering about the name, originally, it was Bernoulli who proved that $p_q(k,n)$ we derived in this article is equal to the value of the $k$th term of the polynomial expansion of the binomial power $(q + (1-q))^n$. Careful, don't collapse it. Obviously, it needs to resolve to $1$, we're talking about probabilities.
The distribution itself is inherently discrete which makes defining the cumulative distribution function rather trivial. As the cumulative distribution function tells us the probability that a random variable will end up being less than or equal to $k$, it merely amounts to adding up discrete probabilities up to $k$:
$$ P_q(k, n) = \sum_{i=0}^{k} { {n \choose i} q^i(1-q)^{n-i} } $$
What value to expect?
Like all distributions, we need to discuss the expected value of a random variable drawn from it. In this case, it simply comes down to the average of all the possible values weighted by their probability. You already know how the average is defined from childhood, but if you're wondering why it is defined the way it is, I wrote an article on the subject which gives it an intuitive treatment. As expected, we start with:
$$ \mu = \frac{ \sum_{i=0}^{n} { x_i w_i } } {\sum_{i=0}^{n} { w_i }} = \sum_{i=0}^{n} { x_i p(x_i) } $$
Substituting the binomial distribution function for $p(x)$ and $k$ for $x_i$ which can neatly alias the iterator $i$:
$$ \mu = \sum_{k=0}^{n} { k \space {n \choose k} q^k(1-q)^{n-k} } = \sum_{k=0}^{n} { k \space \frac{n!}{(n-k)!k!} q^k(1-q)^{n-k} } $$
From here, we need to simplify. If we could get rid of the leftmost $k$ in a manner which would make the binomial theorem applicable, we'd be able to completely obliterate the sum. To this end, I'd like to point out the following holds:
$$ {n \choose k} = \frac{n}{k} {n - 1 \choose k - 1} = \frac{n}{k} \frac{(n-1)!}{(k-1)!((n-1) - (k-1))!} \space \iff \space k {n \choose k} = n {n - 1 \choose k - 1} $$
Given this relationship, we can transform the $k$ out of the sum. Furthermore, if it isn't immediately obvious, $(n-1) - (k-1) = n - k$. Here's the result after our first round of transformations:
$$ \mu = \sum_{k=0}^{n} { k \space {n \choose k} q^k(1-q)^{n-k} } = n\sum_{k=1}^{n} { {n - 1 \choose k - 1} q^k(1-q)^{(n-1) - (k-1)} } $$
As $k - 1$ needs to be larger than or equal to $0$, we set the lower limit of the sum to $1$. To make the binomial theorem applicable, we finalize by extracting a single factor of $q$. Then, we just transform the range to make it more readable by using $j = k - 1$ and $m = n - 1$:
$$\begin{split} \mu &= n\sum_{k=1}^{n} { {n - 1 \choose k - 1} q^k(1-q)^{(n-1) - (k-1)} } \\ & = nq\sum_{k=1}^{n} { {n - 1 \choose k - 1} q^{k-1}(1-q)^{(n-1) - (k-1)} } \\ & = nq\sum_{j=0}^{m} { {m \choose j} q^{j}(1-q)^{m - j} } \\ \end{split}$$
And now we just apply it:
$$ \mu = nq\sum_{j=0}^{m} { {m \choose j} q^{j}(1-q)^{m - j} } = nq(q + (1-q))^m = nq $$
This is my preferred way of arriving at the mean, other approaches feel either circular (depending on the knowledge of the mean in the first place) or are just convoluted. The same approach works for the variance, so I will just tell you it's equal to $nq(1-q)$ should you decide to work it out yourself. Remember, variance is defined as the expected value of the squared deviation of a random variable drawn from the distribution to the mean of the distribution. Simplified, it comes down to:
$$ E[(X - E[X])^2] = E[X^2 - 2XE[X] + E[X]^2] = E[X^2] - 2E[X]^2 + E[X]^2 = E[X^2] - E[X]^2$$
You already know the squared expected value as it is the mean squared, $(nq)^2$, all you have to do is re-do the dance we did before to calculate the expected value of the squared random variable, meaning you calculate the sum of squares of the possible values weighted by the associated probabilities. Enjoy.