DEV Community

Cover image for Binomial Test
Abzal Seitkaziyev
Abzal Seitkaziyev

Posted on • Updated on

Binomial Test

Hypothesis testing using binomial distribution

Here we will use the binomial probability distribution function for the exact binomial test. For example, we played a board game against a computer and found that it is quite easy to win the game. So, one of the players has a hypothesis that a die roll is not fully random, but biased to the player’s advantage. So he checked the stats and found that out of 100 rolls, he had 23 ‘sixes’. Is the player’s assumption correct that the game is biased to give more ‘sixes’ to a human player?

So, the expected value for this case is 100*⅙=16.7, while the observed value = 23.
Let’s do the exact binomial test and it will be one-tailed test.
The null hypothesis is that the probability of getting ‘6’ p = ⅙,
The alternative hypothesis is that p>⅙.
For this exercise, we will use critical value alpha = 0.05, so if our p_value calculated using binomial distribution is less than 0.05 then we can reject the null hypothesis. Because the p_value is just a conditional probability - the probability of the particular event given the null hypothesis is true. For example, if p_value = 0.01 it means there is 1% probability of getting this observation (23 ‘sixes’ out of 100 rolls) when the null hypothesis is true (die is fair). But if p_value = 0.1 then there is 10% probability that we can observe 23 sixes out of 100 roles when the null hypothesis is true.

Using binomial cumulative mass distribution:

Alt Text

Because p_value=0.063>0.05, we cannot reject the null hypothesis (fail to reject). Basically, there is more than 5% chance that the null hypothesis is true.

But what if we continued to play and got the same observed value = 23, meaning we got 46 6s out of 200 rolls. Let’s check this potential situation.

Alt Text

In this case p_value <0.05, and we would reject the null hypothesis.

P_values for both scenarios are shown below.
Alt Text

Conclusion

The binomial test example can be used as an exact test for hypothesis testing without calculation test statistic as p_value can be calculated by using binomial pmf.

Top comments (1)

Collapse
 
mccurcio profile image
Matt Curcio

Love that Data Science!