[porto_container animation_duration=“1000” animation_delay=“0”][/porto_container]

## The binomial distribution

I think the bino­mi­al dis­tri­b­u­tion is the most fun of all dis­tri­b­u­tions. In this sec­tion you will need your skills in prob­a­bil­i­ty the­o­ry. Here I elab­o­rate on the exam­ple about Heads and Tails. The bino­mi­al dis­tri­b­u­tion can for exam­ple be used to check if a coin real­ly is fair; is the prob­a­bil­i­ty of a Head real­ly 0.5?

In the bino­mi­al dis­tri­b­u­tion you only need to be con­cerned about two out­comes; Head or Tail, yes or no, present or absent, 1 or 0. From every sin­gle toss of a coin, you can have the out­come of either a Head or a Tail. Every time you ask some­one if he or she likes broc­coli you can get either yes or no. This vari­able is there­fore dis­crete; it is on the nom­i­nal scale. Head or Tail does not have an inter­nal order.

The bino­mi­al dis­tri­b­u­tion id defined by the  fol­low­ing equation:

where $P$ is the prob­a­bil­i­ty of get­ting a com­bi­na­tion of a spe­cif­ic out­come  $x$ times in $k$ tri­als, $p$ is the prob­a­bil­i­ty of the out­come and $q = 1-p$ =is the prob­a­bil­i­ty of the oth­er outcome.

This equa­tion looks quite intim­i­dat­ing at a first glance, but it is quite straight­for­ward actu­al­ly. What the equa­tion does is to cal­cu­late the prob­a­bil­i­ty of get­ting a com­bi­na­tion with a spe­cif­ic num­ber of out­comes on a spe­cif­ic num­ber of trials.

Exam­ple

If you toss a coin 3 times, what is the prob­a­bil­i­ty of get­ting 2 Heads when the prob­a­bil­i­ty of get­ting a Head is 0.5?

Answer: The prob­a­bil­i­ty is 0.375 to get a com­bi­na­tion with 2 Heads in 3 toss­es when p =0.5.

How to do it in R

```dbinom(2,3,prob=0.5)
```

Below I present the bino­mi­al dis­tri­b­u­tion for 10 tri­als and p = 0.5:

When p = 0.5 the dis­tri­b­u­tion is sym­met­ric, but see what hap­pens when p=0.2:

Now, the dis­tri­b­u­tion is asym­met­ri­cal. Thus, the dis­tri­b­u­tion only con­forms to a per­fect nor­mal bell-shaped dis­tri­b­u­tion when p =0.5.

### Important to remember:

In the bino­mi­al dis­tri­b­u­tion you are deal­ing with two out­comes that you can observe from a trial.

You can use the bino­mi­al dis­tri­b­u­tion to answer the fol­low­ing question:

I know the prob­a­bil­i­ty get­ting a Head with my coin is 0.5, what is the prob­a­bil­i­ty of get­ting 2 Heads in 3 tosses?”

### More in depth

How does the equa­tion for the bino­mi­al dis­tri­b­u­tion work?

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

The prob­a­bil­i­ty of get­ting a Head in every toss is p= 0.5 and the prob­a­bil­i­ty of get­ting a Tail is 1-p=q= 0.5.

When toss­ing the coin, say, three times you can get one of the eight fol­low­ing observations:

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 prob­a­bil­i­ty of each of these com­bi­na­tions is:

Do you see a pat­tern? If you are not con­cerned with in which order the Head and Tail comes in the three toss­es there are real­ly only four unique combinations:

So the prob­a­bil­i­ty of get­ting 3, 0, 2 or 1 Head in three toss­es is equal to the sum of the prob­a­bil­i­ty of all com­bi­na­tions con­tain­ing 3, 0, 2 or 1 Head:

To sim­pli­fy this table:

But how are we cal­cu­lat­ing the num­ber of com­bi­na­tions with $x$ num­ber of Heads. We have just dealt with 3 toss­es now, but what if we are toss­ing the coin 10 times. How many com­bi­na­tions do we get for 3 Heads? The answer is 120. And for 100 toss­es? The answer is 161 700. From this it is clear that we don’t have time to make tables even when deal­ing with a num­ber of toss­es as low as 10.

So to cal­cu­late the prob­a­bil­i­ty of a spe­cif­ic num­ber of Heads (X) in k toss­es we are mul­ti­ply­ing the num­ber of com­bi­na­tions © con­tain­ing that num­ber of Heads with the prob­a­bil­i­ty of each of these com­bi­na­tions (C x pC). Do you fol­low? We are using one of the prin­ci­ples from the prob­a­bil­i­ty the­o­ry here;  we want the prob­a­bil­i­ty for a com­bi­na­tion con­tain­ing 2 Heads. There are three com­bi­na­tions with 2 heads, so we add them: 0.125 + 0.125 + 0.125 = 0.125 x 3 = 0.375. The prob­a­bil­i­ty for all pos­si­ble com­bi­na­tions adds up to 1: 0.125 + 0.375 + 0.375 + 0.125 = 1.

Now we are on the way to an equa­tion for cal­cu­lat­ing the prob­a­bil­i­ty of X num­ber of Heads in k toss­es. Sim­pli­fied this equa­tion is P (X, k) = C x pc

To cal­cu­late the num­ber of com­bi­na­tions ($C$) with $x$ num­ber of a spe­cif­ic out­come (e.g. Heads) on $k$ num­ber of tri­als (toss­es) you use the fol­low­ing equation:

Exam­ple

Cal­cu­late the num­ber of com­bi­na­tions you can get con­tain­ing 6 Heads on 20 tosses.

$k$= 20,  $x$= 6

Use the equation:

The answer is: You can get 38 760 com­bi­na­tions with 6 Heads on 20 tosses

Ok, so now we have an equa­tion to cal­cu­late the num­ber of com­bi­na­tions ©. But how do we cal­cu­late the prob­a­bil­i­ty of each com­bi­na­tion? This is the most straight­for­ward part. You take the prob­a­bil­i­ty of the out­come (e.g. p = 0.5) and raise it to the pow­er of the num­ber of times  you will receive the out­come (e.g. 3 times): $p^x$But for the rest of the toss­es( $k-x$), you will receive the oth­er out­come ($q$).

On $k$ toss­es you use the fol­low­ing equation:

where $P_c$ is the prob­a­bil­i­ty of one com­bi­na­tion with $x$ nr of heads (or 1:s) in $k$ toss­es, $p$ is the prob­a­bil­i­ty of get­ting a head (or 1) and $q$ is the prob­a­bil­i­ty of get­ting a tail (or 0).

Exam­ple

Cal­cu­late the prob­a­bil­i­ty for each com­bi­na­tion con­tain­ing 6 Heads in 20 toss­es where the prob­a­bil­i­ty of get­ting a Head in each toss is p = 0.5 and a Tail is q = 1- p = 0.5

$k$= 20,  $x$ = 6

Use the equation:

Answer: The prob­a­bil­i­ty for each com­bi­na­tion con­tain­ing 6 Heads in 20 toss­es is 9.53 x 10-7

Now, we are get­ting some­where. Then we com­bine these to equa­tions (C and Pc). That is the equa­tion for the bino­mi­al distribution:

where  $P$ is the prob­a­bil­i­ty of get­ting a com­bi­na­tion of a spe­cif­ic out­come  $x$ times in $k$ tri­als, $p$ is the prob­a­bil­i­ty of the out­come and  $q$= 1 —  $p$ is the prob­a­bil­i­ty of the oth­er outcome.

Exam­ple

Cal­cu­late the prob­a­bil­i­ty of get­ting a com­bi­na­tion with 6 Heads in 20 toss­es where the prob­a­bil­i­ty of a Head is p=0.5.

$k$= 20,  $x$= 6

Use the equa­tion for the bino­mi­al distribution:

Answer: The prob­a­bil­i­ty of get­ting a com­bi­na­tion with 6 Heads on 20 toss­es is 0.037.