Before understanding the Binomial Distribution, we must define its building block: the Bernoulli Trial.
A Bernoulli trial is a random experiment with exactly two possible outcomes: * Success (S): The outcome we are interested in (coded as 1). * Failure (F): The opposite outcome (coded as 0).
Examples: * Tossing a coin (Heads or Tails). * Testing a lightbulb (Working or Defective). * A customer making a purchase (Yes or No).
The Binomial distribution represents the number of “Successes” in a fixed number of independent Bernoulli trials.
To use the Binomial model, four conditions must be met: 1. Binary: There are only two possible outcomes for each trial. 2. Independent: The outcome of one trial does not affect the others. 3. Number: The number of trials (\(n\)) is fixed in advance. 4. Success: The probability of success (\(p\)) is the same for each trial.
The probability of getting exactly \(k\) successes in \(n\) trials is given by the Probability Mass Function (PMF):
\[P(X = k) = \binom{n}{k} p^k (1-p)^{n-k}\]
Where: * \(\binom{n}{k} = \frac{n!}{k!(n-k)!}\) (The number of ways to arrange \(k\) successes) * \(p\) = Probability of success * \(1-p\) = Probability of failure (\(q\)) * \(n\) = Number of trials * \(k\) = Number of observed successes (\(k = 0, 1, 2, ..., n\))
A factory produces LEDs, and 5% of them are defective. If a random sample of 10 LEDs is chosen, what is the probability that exactly 2 are defective?
## [1] 0.0746348
An e-commerce company finds that 15% of people who receive a promotional email make a purchase. If they send the email to 20 people, what is the probability that at most 3 people make a purchase?
## [1] 0.6477252
A new drug has an 80% success rate in treating a specific symptom. If 15 patients are treated, what is the probability that more than 12 patients recover?
# Using lower.tail = FALSE to get P(X > 12)
pbinom(q = 12, size = 15, prob = 0.80, lower.tail = FALSE)## [1] 0.3980232
As \(n\) increases or \(p\) gets closer to 0.5, the Binomial distribution begins to look more “Normal” (bell-shaped).
# Parameters
n_val <- 50
p_val <- 0.3
# Data frame for plotting
df <- data.frame(
successes = 0:n_val,
probability = dbinom(0:n_val, size = n_val, prob = p_val)
)
ggplot(df, aes(x = successes, y = probability)) +
geom_bar(stat = "identity", fill = "steelblue", color = "white") +
labs(title = paste("Binomial Distribution (n =", n_val, ", p =", p_val, ")"),
x = "Number of Successes",
y = "Probability") +
theme_minimal()| Function | Purpose | Example |
|---|---|---|
dbinom() |
Probability Mass Function (finds \(P(X = k)\)) | dbinom(2, 10, 0.5) |
pbinom() |
Cumulative Distribution (finds \(P(X \le k)\)) | pbinom(2, 10, 0.5) |
qbinom() |
Quantile function (finds \(k\) for a given percentile) | qbinom(0.95, 10, 0.5) |
rbinom() |
Generate random numbers from a binomial dist. | rbinom(5, 10, 0.5) |
```