Probability theory 101

Probability theory and Distributions

Bongani Ncube(3002164)

2025-07-07

Statistical Inference

  • Very often in a statistical investigation it is impossible to consider the entire population of interest, so we look at a sample from the population.
  • The process of drawing a conclusion about the population on the basis of our sample is known as statistical inference.

Sampling distributions

  • Suppose (hypothetically) that we take lots of samples of 100 babies - we would then get lots of values for the mean and we can look at the distribution of these values - known as the sampling distribution of the mean.

  • This distribution will have its own mean and variance In this case the square root of the variance is known as the standard error of the mean - a measure of how much the sample mean varies from one sample to another

  • Important result is that if our variable X (e.g. birth weight) has a normal distribution with mean \(\mu\) and variance \(\sigma^2\), then the sampling distribution of the mean will also be normal with mean \(\mu\) and variance \(\frac{\sigma^2}{n}\)
    So that \(s.e.(mean) = \frac{\sigma^2}{n}\)

Bernoulli

If \(X\) is the result of a trial with two outcomes of probability \(P(X = 1) = \pi\) and \(P(X = 0) = 1 - \pi\), then \(X\) is a random variable with a Bernoulli distribution

\[f(x) = \pi^x (1 - \pi)^{1 - x}, \hspace{1cm} x \in (0, 1)\]

with \(E(X) = \pi\) and \(Var(X) = \pi(1 - \pi)\).

Binomial

If \(X\) is the count of successful events in \(n\) identical and independent Bernoulli trials of success probability \(\pi\), then \(X\) is a random variable with a binomial distribution \(X \sim Bin(n,\pi)\)

\[f(x;n, \pi) = \frac{n!}{x!(n-x)!} \pi^x (1-\pi)^{n-x} \hspace{1cm} x \in (0, 1, ..., n), \hspace{2mm} \pi \in [0, 1]\]

with \(E(X)=n\pi\) and \(Var(X) = n\pi(1-\pi)\).

The probability 2 out of 10 coin flips are heads if the probability of heads is 0.3:

dbinom(x = 2, size = 10, prob = 0.3)
[1] 0.2334744

What is the probability of <=2 heads in 10 coin flips where probability of heads is 0.3? The cumulative probability is the sum of the first three bars in the simulation above. Function pbinom() calculates the cumulative binomial probability.

pbinom(q = 2, size = 10, prob = 0.3, lower.tail = TRUE)
[1] 0.3827828

What is the expected number of heads in 25 coin flips if the probability of heads is 0.3?

The expected value, \(\mu = np\), is 7.5. Here’s an empirical test from 10,000 samples.

mean(rbinom(n = 10000, size = 25, prob = .3))
[1] 7.4805

The variance, \(\sigma^2 = np (1 - p)\), is 5.25. Here’s an empirical test.

var(rbinom(n = 10000, size = 25, prob = .3))
[1] 5.245901

Suppose X and Y are independent random variables distributed \(X \sim Bin(10, .6)\) and \(Y \sim Bin(10, .7)\). What is the probability that either variable is <=4?

Let \(P(A) = P(X<=4)\) and \(P(B) = P(Y<=4)\). Then \(P(A|B) = P(A) + P(B) - P(AB)\), and because the events are independent, \(P(AB) = P(A)P(B)\).

p_a <- pbinom(q = 4, size = 10, prob = 0.6, lower.tail = TRUE)
p_b <- pbinom(q = 4, size = 10, prob = 0.7, lower.tail = TRUE)
p_a + p_b - (p_a * p_b)
[1] 0.2057164

A couple other points to remember:

  • The Bernoulli distribution is a special case of the binomial with \(n = 1\).
  • The binomial distribution assumes independent trials. If you sample without replacement from a finite population, use the hypergeometric distribution.

Poission

If \(X\) is the number of successes in \(n\) (many) trials when the probability of success \(\lambda / n\) is small, then \(X\) is a random variable with a Poisson distribution \(X \sim Poisson(\lambda)\)

\[f(x;\lambda) = \frac{e^{-\lambda} \lambda^x}{x!} \hspace{1cm} x \in (0, 1, ...), \hspace{2mm} \lambda > 0\]

with \(E(X)=\lambda\) and \(Var(X) = \lambda\).

The Poisson likelihood function is

\[L(\lambda; x) = \prod_{i=1}^N f(x_i; \lambda) = \prod_{i=1}^N \frac{e^{-\lambda} \lambda^x_i}{x_i !} = \frac{e^{-n \lambda} \lambda^{\sum x_i}}{\prod x_i}.\]

The Poisson loglikelihood function is

\[l(\lambda; x) = \sum_{i=1}^N x_i \log \lambda - n \lambda.\]

One can show that the loglikelihood function is maximized at

\[\hat{\lambda} = \sum_{i=1}^N x_i / n.\]

Thus, for a Poisson sample, the MLE for \(\lambda\) is just the sample mean.

\(Poison(\lambda) \rightarrow Bin(n, \pi)\) when \(n\pi = \lambda\) and \(n \rightarrow \infty\) and \(\pi \rightarrow 0\). Because the Poisson is limit of the \(Bin(n, \pi)\), it is useful as an approximation to the binomial when \(n\) is large (\(n>=20\)) and \(\pi\) small (\(p<=0.05\)).

For example, suppose a baseball player has a p=.03 chance of hitting a homerun. What is the probability of X>=20 homeruns in 500 at-bats? This is a binomial process because the sample size is fixed.

pbinom(q = 20, size = 500, prob = 0.03, lower.tail = FALSE)
[1] 0.07979678

But \(n\) is large and \(\pi\) is small, so the Poisson distribution will work well too.

ppois(q = 20, lambda = 0.03 * 500, lower.tail = FALSE)
[1] 0.08297091

Continuous Distributions

Normal

Random variable \(X\) is distributed \(X \sim N(\mu, \sigma^2)\) if

\[f(X)=\frac{{1}}{{\sigma \sqrt{{2\pi}}}}e^{-.5(\frac{{x-\mu}}{{\sigma}})^2}\].

Suppose IQ scores are distributed \(X \sim N\left(100, 16^2\right)\).

pnorm(q = 90, mean = 100, sd = 16, lower.tail = TRUE)
## [1] 0.2659855

pnorm(q = 140, mean = 100, sd = 16, lower.tail = FALSE)
## [1] 0.006209665

pnorm(q = 114, mean = 100, sd = 16, lower.tail = TRUE) -
  pnorm(q = 92, mean = 100, sd = 16, lower.tail = TRUE)
## [1] 0.5006755

qnorm(p = 0.90, mean = 100, sd = 16, lower.tail = TRUE)
## [1] 120.5048

By the central limit theorem (CLT) the binomial distribution \(X \sim B(n,p)\) approaches the normal distribution with mean \(\mu = n p\) and variance \(\sigma^2=np(1-p)\) as \(n \rightarrow \infty\). The approximation is useful when the expected number of successes and failures is at least 5, \(np>=5\) and \(n(1-p)>=5\).

Suppose a measure requires p>=50% popular to pass. A sample of n=1,000 yields x=460 approvals. What is the probability that the overall population approves, P(X)>0.5?

# Exact binomial
pbinom(q = 460, size = 1000, prob = 0.50, lower.tail = TRUE)
## [1] 0.006222073

# Normal approximation
pnorm(q = 460, mean = 0.50 * 1000, sd = sqrt(1000 * 0.50 * (1 - 0.50)), lower.tail = TRUE)
## [1] 0.005706018

By the central limit theorem (CLT) the Poisson distribution \(x~P(\lambda)\) approaches the normal distribution with mean \(\mu = \lambda\) and variance \(\sigma^2 = \lambda\) as \(n \rightarrow \infty\). The approximation is useful for large values of \(\lambda\).

Suppose the annual number of earthquakes registering at least 2.5 on the Richter Scale and having an epicenter within 40 miles of downtown Memphis follows a Poisson distribution with mean \(\lambda=6.5\). What is the probability that at least \(x>=9\) such earthquakes will strike next year?

# Exact Poisson
ppois(q = 9 - 1, lambda = 6.5, lower.tail = FALSE)
## [1] 0.208427

# Normal approximation
pnorm(q = 9 - 0.5, mean = 6.5, sd = sqrt(6.5), lower.tail = FALSE)
## [1] 0.2163838

Estimate the population from the sample using the CLT. Suppose a person’s blood pressure typically measures \(160 \pm 20\) mm. If one takes n=5 blood pressure readings, what is the probability the average will be <=150?*

pnorm(q = 150, mean = 160, sd = 20 / sqrt(5), lower.tail = TRUE)
## [1] 0.1317762
Back to top