Binomial distribution and binomial test

How do we analyze proportions?

Binomial distribution equation

Binomial distribution: the distribution “successes” of many independent trials. There are only two possible outcomes, success and non-success.

Assumptions

  • Each trial is independent of the other
  • The number of “n” trials is fixed
  • The probability of success, “p”, is the same for each trial

Sampling distribution of the proportion

Proportion of X successes out of n trials (p-hat).

Population standard error of p-hat.

Binomial test: used to test hypothesis that the population proportion (p) is the same as the null expectation (p0).

# Six-sided die flipped 24 times and lands on three exactly 6 times
binom.test(x = 6, n = 24, p = 1 / 6, alternative = "greater")
# Flip coin 30 times and it lands on heads exactly 19 times
binom.test(x = 19, n = 30, p = 1 / 2, alternative = "greater")
view raw binomial_test.r hosted with ❤ by GitHub
R code
# Binomial test in Python
from scipy.stats import binom_test
# Six-sided die flipped 24 times and lands on three exactly 6 times
x = binom_test(x=6, n=24, p=1/6, alternative='greater')
print(x)
# Flip coin 30 times and it lands on heads exactly 19 times
y = binom_test(x=19, n=30, p=1/2, alternative='greater')
print(y)
Python code

Estimating standard error and confidence intervals of the proportion

Approximate standard error

Agresti-Coull method calculating the CI of the proportion