## The binomial distribution

I think the binomial distribution is the most fun of all distributions. In this section you will need your skills in probability theory. Here I elaborate on the example about Heads and Tails. The binomial distribution can for example be used to check if a coin really is fair; is the probability of a Head really 0.5?

**In the binomial distribution you only need to be concerned about two outcomes**; Head or Tail, yes or no, present or absent, 1 or 0. From every single toss of a coin, you can have the outcome of either a Head or a Tail. Every time you ask someone if he or she likes broccoli you can get either yes or no. This variable is therefore discrete; it is on the nominal scale. Head or Tail does not have an internal order.

The binomial distribution id defined by the following equation:

where * *is the probability of getting a combination of a specific outcome times in trials, * *is the probability of the outcome and =is the probability of the other outcome.

This equation looks quite intimidating at a first glance, but it is quite straightforward actually. What the equation does is to calculate the probability of getting a combination with a specific number of outcomes on a specific number of trials.

**Example **

If you toss a coin 3 times, what is the probability of getting 2 Heads when the probability of getting a Head is 0.5?

Answer: The probability is 0.375 to get a combination with 2 Heads in 3 tosses when *p *=0.5.

*How to do it in R*

dbinom(2,3,prob=0.5)

Below I present the binomial distribution for 10 trials and *p *= 0.5:

When *p *= 0.5 the distribution is symmetric, but see what happens when *p*=0.2:

Now, the distribution is asymmetrical. Thus, the distribution only conforms to a perfect normal bell-shaped distribution when *p =*0.5.

### Important to remember:

In the binomial distribution you are dealing with two outcomes that you can observe from a trial.

You can use the binomial distribution to answer the following question:

“I know the probability getting a Head with my coin is 0.5, what is the probability of getting 2 Heads in 3 tosses?”

### More in depth

**How does the equation for the binomial distribution work? **

Ok, now let’s go on to look at some probabilities.

The probability of getting a Head in every toss is *p*= 0.5 and the probability of getting a Tail is 1-*p*=*q*= 0.5.

When tossing the coin, say, three times you can get one of the eight following observations:

HHH = 3 Heads

TTT = 3 Tails = 0 Heads

HHT = 1 Tail = 2 Heads

HTH = 1 Tail = 2 Heads

THH = 1 Tail = 2 Heads

TTH = 2 Tails = 1 Head

THT = 2 Tails = 1 Head

HTT = 2 Tails = 1 Head

The probability of each of these combinations is:

Do you see a pattern? If you are not concerned with in which order the Head and Tail comes in the three tosses there are really only four unique combinations:

So the probability of getting 3, 0, 2 or 1 Head in three tosses is equal to the sum of the probability of all combinations containing 3, 0, 2 or 1 Head:

To simplify this table:

But how are we calculating the number of combinations with number of Heads. We have just dealt with 3 tosses now, but what if we are tossing the coin 10 times. How many combinations do we get for 3 Heads? The answer is 120. And for 100 tosses? The answer is 161 700. From this it is clear that we don’t have time to make tables even when dealing with a number of tosses as low as 10.

**So to calculate the probability of a specific number of Heads (X) in k tosses we are multiplying the number of combinations (C) containing that number of Heads with the probability of each of these combinations (C x p_{C}).** Do you follow? We are using one of the principles from the probability theory here; we want the probability for a combination containing 2 Heads. There are three combinations with 2 heads, so we add them: 0.125 + 0.125 + 0.125 = 0.125 x 3 = 0.375. The probability for all possible combinations adds up to 1: 0.125 + 0.375 + 0.375 + 0.125 = 1.

Now we are on the way to an equation for calculating the probability of X number of Heads in *k *tosses. Simplified this equation is *P *(X, *k*) = C x *p*_{c}

To calculate the number of combinations () with number of a specific outcome (e.g. Heads) on number of trials (tosses) you use the following equation:

**Example**

Calculate the number of combinations you can get containing 6 Heads on 20 tosses.

= 20, = 6

Use the equation:

The answer is: You can get 38 760 combinations with 6 Heads on 20 tosses

Ok, so now we have an equation to calculate the number of combinations (C). But how do we calculate the probability of each combination? This is the most straightforward part. You take the probability of the outcome (e.g. *p *= 0.5) and raise it to the power of the number of times you will receive the outcome (e.g. 3 times): *. *But for the rest of the tosses( ), you will receive the other outcome ().

On tosses you use the following equation:

where is the probability of one combination with nr of heads (or 1:s) in tosses, is the probability of getting a head (or 1) and is the probability of getting a tail (or 0).

**Example**

Calculate the probability for each combination containing 6 Heads in 20 tosses where the probability of getting a Head in each toss is *p *= 0.5 and a Tail is *q* = 1- *p *= 0.5

= 20, = 6

Use the equation:

Answer: The probability for each combination containing 6 Heads in 20 tosses is 9.53 x 10^{-7 }

^{ }Now, we are getting somewhere. Then we combine these to equations (C and *P _{c}*). That is the equation for the binomial distribution:

where * * is the probability of getting a combination of a specific outcome times in trials, * *is the probability of the outcome and = 1 – is the probability of the other outcome.

**Example **

Calculate the probability of getting a combination with 6 Heads in 20 tosses where the probability of a Head is *p*=0.5.

= 20, = 6

Use the equation for the binomial distribution:

Answer: The probability of getting a combination with 6 Heads on 20 tosses is 0.037.