Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.



14.1 Random Variables: The Formal Definition

In Chapters 2 and 3, we built the foundations of probability: sample spaces, events, axioms, conditional probability, and counting. Every calculation started with a sample space SS and asked about the probability of some event ASA \subseteq S. This framework is powerful, but it has a practical limitation: most real questions are about numbers, not about raw outcomes.

Consider the experiment of rolling two fair dice. The sample space contains 36 ordered pairs: (1,1),(1,2),,(6,6)(1,1), (1,2), \ldots, (6,6). But when you play a board game, you don’t care which die showed what — you care about the sum. When a gambler bets on the total, the relevant quantity is a single number between 2 and 12, not a pair of faces.

We need a way to go from outcomes to numbers. That is exactly what a random variable does.

The word “random” can be misleading. A random variable is not a variable in the algebraic sense (like solving 3x+1=73x + 1 = 7 for xx), and it is not random in the colloquial sense of “unpredictable.” It is a function — a deterministic mapping — applied to the outcome of a random experiment. The randomness comes from the experiment, not from the function itself.

Notation convention. Throughout this book, we follow a strict convention:

So YY is the random variable “the number of heads when you toss three coins,” and y=2y = 2 is one particular value it might take. The expression P(Y=y)P(Y = y) reads “the probability that the random variable YY takes the value yy.”

1.1Discrete vs. Continuous Random Variables

Random variables come in two fundamental types.

In plain terms, a discrete random variable counts things. The number of emails you receive in an hour (0, 1, 2, 3, ...), the number of heads in ten coin tosses (0, 1, 2, ..., 10), the number of defective items in a shipment — all of these are discrete. You can list the possible values, even if the list is infinitely long.

A continuous random variable, by contrast, can take any value in some interval of real numbers. The temperature outside, the time until a light bulb burns out, the exact weight of a bag of flour — these quantities can, in principle, take any value in a continuous range. We will study continuous random variables in Chapter 5. For now, our focus is entirely on discrete random variables.

1.2Building a Random Variable: Examples

The best way to understand random variables is to build several from scratch.

1.3Why Random Variables Matter

You might wonder: if a random variable is just a function on the sample space, why bother defining it? Why not just work with events directly?

The answer is power. Once we attach numbers to outcomes, we can:

The rest of this chapter develops all of these ideas. We start by asking: given a discrete random variable YY, how do we describe its probability structure completely?

1.4Seeing It in R

Before moving to formal definitions, let us see a random variable in action. The following R code simulates the playlist experiment from Example 4.1 ten thousand times and counts how many pop songs appear in each selection.

#| label: rv-simulation
#| fig-cap: "Simulated distribution of Y = number of pop songs in a 3-song selection"

set.seed(42)
n_sim <- 10000

# Library: 4 pop songs (labeled 1) and 6 hip-hop songs (labeled 0)
library_songs <- c(rep(1, 4), rep(0, 6))

# Simulate: select 3 songs without replacement, count pop songs
Y <- replicate(n_sim, sum(sample(library_songs, size = 3, replace = FALSE)))

# Display relative frequencies
table(Y) / n_sim
barplot(table(Y) / n_sim,
        main = "Simulated Distribution of Y (10,000 Repetitions)",
        xlab = "Number of Pop Songs (Y)",
        ylab = "Relative Frequency",
        col = "steelblue",
        border = "white")

Run this code. You will see that Y=1Y = 1 is the most common outcome, occurring roughly half the time. In the next section, we will compute these probabilities exactly using probability mass functions — and the simulation will confirm our theory.



1.5Exercises: Section 4.1

4.1.1. A rideshare driver completes trips over the course of a day. On a given day, she might complete 0, 1, 2, ..., or as many as 20 trips. Let YY denote the number of trips she completes.

(a) Is YY a discrete or continuous random variable? Explain. (b) What is the set of possible values for YY? (c) Give an example of an event expressed in terms of YY and explain what it means in plain language.

4.1.2. Two students are randomly selected from a study group of 5 computer science majors and 3 mathematics majors. Let XX denote the number of mathematics majors selected.

(a) List the possible values of XX. (b) Describe the sample space SS and explain how XX maps each outcome to a number. (c) Is this an example of a discrete or continuous random variable?

4.1.3. For each of the following, identify the random variable, state whether it is discrete or continuous, and list its possible values (or describe the range if continuous).

(a) A tech company tests 15 newly manufactured circuit boards and records how many pass quality inspection. (b) A weather station records the exact amount of rainfall (in inches) during a 24-hour period. (c) A social media post is shared by followers, and a researcher counts the total number of shares after 48 hours. (d) A runner records her exact finishing time (in minutes and seconds) for a 5K race.

4.1.4. Consider the experiment of tossing a fair coin three times. The sample space is S={HHH,HHT,HTH,HTT,THH,THT,TTH,TTT}S = \{HHH, HHT, HTH, HTT, THH, THT, TTH, TTT\}.

(a) Define the random variable Y=Y = the number of heads. List the value of YY for each outcome in SS. (b) Define a different random variable WW on the same sample space as follows: W=1W = 1 if at least two consecutive tosses show the same face, and W=0W = 0 otherwise. List the value of WW for each outcome in SS. (c) Find P(Y=2)P(Y = 2) and P(W=1)P(W = 1).


24.2 Probability Mass Functions and Cumulative Distribution Functions

2.1The Probability Mass Function

Once we have a discrete random variable YY, the most natural question is: for each value yy that YY can take, what is P(Y=y)P(Y = y)?

The PMF p(y)p(y) assigns a probability to each possible value of YY. For values that YY cannot take, we have p(y)=0p(y) = 0. The following theorem states the two properties that every valid PMF must satisfy.

Property 1 says that probabilities are between 0 and 1 (they are valid probabilities). Property 2 says that the total probability across all possible values is exactly 1 (something must happen). These two properties are the only requirements. Any function satisfying them is a valid PMF.

2.2The Cumulative Distribution Function

The PMF tells us the probability of each individual value. But we often need to answer questions like “what is the probability that YY is at most 3?” or “what is the probability that YY is between 2 and 5?” The cumulative distribution function makes these calculations easy.

The CDF accumulates probability from left to right. At any point yy, F(y)F(y) tells you the total probability that has “piled up” at or below that value.

Key properties of the CDF:

  1. FF is non-decreasing: if a<ba < b, then F(a)F(b)F(a) \leq F(b).

  2. limyF(y)=0\lim_{y \to -\infty} F(y) = 0 and limyF(y)=1\lim_{y \to \infty} F(y) = 1.

  3. For a discrete random variable, FF is a step function — it jumps at each value where p(y)>0p(y) > 0 and is flat in between.

  4. The PMF can be recovered from the CDF: p(y)=F(y)F(y)p(y) = F(y) - F(y^-), where F(y)F(y^-) is the value of FF just to the left of yy.

2.3Representing Distributions: Table, Formula, Graph

A probability distribution can be represented in three equivalent ways:

  1. A table — lists each value and its probability (best for small, finite distributions).

  2. A formula — gives p(y)p(y) as a mathematical expression (best for named distributions like the Binomial).

  3. A probability histogram — a bar graph where the height (or area) of each bar equals the probability. This gives a visual picture of where the probability is concentrated.

For the CDF, the graph is always a staircase (step function), climbing from 0 to 1.

2.4Seeing It in R

#| label: pmf-cdf-plot
#| fig-cap: "PMF and CDF for the animal shelter adoption data"

# Animal shelter PMF
y_vals <- 0:4
pmf <- c(0.15, 0.30, 0.25, 0.20, 0.10)

par(mfrow = c(1, 2))

# PMF (probability histogram)
barplot(pmf, names.arg = y_vals,
        main = "PMF: p(y)",
        xlab = "y (dogs adopted)", ylab = "p(y)",
        col = "steelblue", border = "white", ylim = c(0, 0.35))

# CDF (step function)
cdf_vals <- cumsum(pmf)
plot(stepfun(y_vals, c(0, cdf_vals)),
     main = "CDF: F(y)",
     xlab = "y", ylab = "F(y)",
     col = "steelblue", lwd = 2,
     verticals = FALSE, pch = 19,
     xlim = c(-1, 5), ylim = c(0, 1))
abline(h = c(0, 1), lty = 3, col = "gray")

par(mfrow = c(1, 1))


2.5Exercises: Section 4.2

4.2.1. A campus coffee shop tracks the number of espresso drinks ordered in the first 10 minutes after opening. Based on past data, the distribution is:

yy012345
p(y)p(y)0.050.150.300.250.150.10

(a) Verify that this is a valid PMF. (b) Find P(Y3)P(Y \geq 3). (c) Construct the CDF F(y)F(y) and write it as a piecewise function. (d) Find P(1<Y4)P(1 < Y \leq 4) using the CDF.

4.2.2. The PMF of a random variable XX is given by p(x)=cx2p(x) = cx^2 for x=1,2,3x = 1, 2, 3.

(a) Find the value of cc. (b) Find P(X2)P(X \leq 2). (c) Find the CDF F(x)F(x).

4.2.3. The CDF of a discrete random variable YY is given by:

F(y)={0if y<10.25if 1y<30.60if 3y<50.90if 5y<71.00if y7F(y) = \begin{cases} 0 & \text{if } y < 1 \\ 0.25 & \text{if } 1 \leq y < 3 \\ 0.60 & \text{if } 3 \leq y < 5 \\ 0.90 & \text{if } 5 \leq y < 7 \\ 1.00 & \text{if } y \geq 7 \end{cases}

(a) What are the possible values of YY? (b) Find the PMF p(y)p(y). (c) Find P(2<Y5)P(2 < Y \leq 5).

4.2.4. A small bakery sells custom cakes. The number of cake orders per day, YY, has the following PMF: p(y)=k(5y)p(y) = k(5-y) for y=0,1,2,3,4y = 0, 1, 2, 3, 4.

(a) Find the value of kk. (b) Find P(Y2)P(Y \geq 2). (c) Construct and plot the CDF of YY. (d) Find the most likely number of orders (the mode).

4.2.5. A random variable XX has the PMF p(x)=(1/3)(2/3)xp(x) = (1/3)(2/3)^{x} for x=0,1,2,x = 0, 1, 2, \ldots.

(a) Verify that this is a valid PMF. (Hint: geometric series.) (b) Find P(X2)P(X \leq 2). (c) Find P(X>4)P(X > 4). (d) Write a general formula for the CDF F(x)F(x) for non-negative integer values of xx.


34.3 Expected Value of a Random Variable

3.1The Definition

Before diving in, let us recall some foundational tools.

The formula says: multiply each possible value by its probability, and add up all the products. Values with high probability contribute more to the sum; values with low probability contribute less. The result is a weighted average, where the weights are the probabilities.

3.2Why This Makes Sense: The Frequency Interpretation

To see why E(Y)=yp(y)E(Y) = \sum y \cdot p(y) is the “long-run average,” suppose we repeat an experiment 1,000,000 times. Consider a random variable YY with the following PMF:

yy012
p(y)p(y)1/41/41/21/21/41/4

In 1,000,000 repetitions, we would expect approximately 250,000 observations of Y=0Y = 0, approximately 500,000 of Y=1Y = 1, and approximately 250,000 of Y=2Y = 2. The average of all 1,000,000 observations would be:

μ(250,000)(0)+(500,000)(1)+(250,000)(2)1,000,000=(0)(14)+(1)(12)+(2)(14)=y=02yp(y)=1.\mu \approx \frac{(250{,}000)(0) + (500{,}000)(1) + (250{,}000)(2)}{1{,}000{,}000} = (0)\left(\frac{1}{4}\right) + (1)\left(\frac{1}{2}\right) + (2)\left(\frac{1}{4}\right) = \sum_{y=0}^{2} y \cdot p(y) = 1.

The expected value E(Y)=1E(Y) = 1 is exactly the center of this symmetric distribution. It is the value around which the outcomes cluster in the long run.

3.3Seeing It in R

#| label: ev-simulation
#| fig-cap: "Simulated long-run average converging to E(Y) = 1.95"

set.seed(123)
y_vals <- 0:4
probs <- c(0.10, 0.25, 0.35, 0.20, 0.10)
true_mean <- sum(y_vals * probs)  # 1.95

# Simulate 5000 days
n <- 5000
downloads <- sample(y_vals, size = n, replace = TRUE, prob = probs)

# Running average
running_avg <- cumsum(downloads) / (1:n)

plot(1:n, running_avg, type = "l", col = "steelblue", lwd = 1.5,
     main = "Running Average Converging to E(Y)",
     xlab = "Number of Days", ylab = "Running Average",
     ylim = c(0, 4))
abline(h = true_mean, col = "red", lwd = 2, lty = 2)
legend("topright", legend = c("Running Average", paste0("E(Y) = ", true_mean)),
       col = c("steelblue", "red"), lwd = c(1.5, 2), lty = c(1, 2))

This plot illustrates the frequency interpretation: the running average of observed values bounces around early on but settles closer and closer to E(Y)=1.95E(Y) = 1.95 as the number of repetitions grows.



3.4Exercises: Section 4.3

4.3.1. A random variable YY has the following PMF:

yy1234
p(y)p(y)0.400.300.200.10

(a) Find E(Y)E(Y). (b) Find E(1/Y)E(1/Y). (c) Is E(1/Y)=1/E(Y)E(1/Y) = 1/E(Y)? What does this tell you about expected values of functions?

4.3.2. A coffee roaster packages beans into bags that are supposed to weigh 12 oz. Due to variation in the filling machine, the number of underweight bags in a random sample of 6 bags has the following distribution:

yy (underweight bags)0123
p(y)p(y)0.550.300.100.05

(a) Find the expected number of underweight bags. (b) If each underweight bag must be repackaged at a cost of $0.75, what is the expected repackaging cost per sample?

4.3.3. A game show contestant spins a wheel with four equally likely outcomes: win $0, win $100, win $500, or win $2000. The contestant must pay an entry fee to play. What is the maximum entry fee that makes this game worth playing (i.e., results in a non-negative expected net gain)?

4.3.4. Verify the expected value from Example 4.9 using R simulation. Generate 100,000 simulated values of YY using the given PMF, compute the sample mean, and compare it to the theoretical expected value of 1.95.


44.4 Expected Value of Functions and Properties of Expectation

4.1The Key Theorem

This theorem is so important that it has a name in the probability literature: the Law of the Unconscious Statistician (LOTUS). The humorous name comes from the fact that students often apply this formula “unconsciously” — without realizing that it is a nontrivial shortcut. The remarkable thing LOTUS tells you is: to find the expected value of g(Y)g(Y), you do not need to derive the distribution of g(Y)g(Y) first. Instead, evaluate gg at each value of YY, multiply by the probability of that value, and sum. The PMF of YY is all you need. This saves enormous work, and we will use LOTUS constantly throughout this course.

4.2Properties of Expected Value

Three fundamental properties of expected value follow directly from the definition. These are tools we will use constantly throughout the rest of this course.

This is intuitive: a constant has no variability, so its “average” is just itself. If you earn exactly $50 every day, your average daily income is $50 — no calculation needed.

In plain language: if every outcome is multiplied by the same constant, the average gets multiplied by that constant too. If each repair costs $40 and you average 3 repairs per day, the average daily repair cost is 40×3=$12040 \times 3 = \$120.

Why this matters: Linearity is arguably the most useful property in all of probability. It says: the expected value of a sum is the sum of the expected values, always, with no conditions on the functions involved.

Combining Theorems 4.3–4.5, we get a result that is used constantly:

E(aY+b)=aE(Y)+b,E(aY + b) = aE(Y) + b,

for any constants aa and bb. The expected value is a linear operator — it passes through addition and scalar multiplication.

4.3Variance and Standard Deviation

Knowing the expected value tells us the center of the distribution, but two distributions can have the same center and very different shapes. Consider two investments:

Both have the same expected value, but Investment B is riskier — its outcomes are spread out. We need a measure of this spread.

The variance measures the average squared distance from the mean. Squaring ensures that deviations above and below the mean both contribute positively. The standard deviation σ\sigma has the same units as YY, making it easier to interpret.

4.4The Variance Shortcut

Computing variance directly from the definition requires calculating (yμ)2(y - \mu)^2 for every value. The following theorem provides a much faster alternative.

This shortcut is almost always faster than the definition. The recipe is:

  1. Compute E(Y)E(Y). Call it μ\mu.

  2. Compute E(Y2)E(Y^2).

  3. Variance =E(Y2)μ2= E(Y^2) - \mu^2.

4.5The Linear Transformation Rule

One more result that we will use repeatedly:

Notice that adding a constant bb shifts the distribution but does not change the variance — spread is not affected by shifting. Multiplying by a constant aa scales the spread by a|a|, so the variance scales by a2a^2.



4.6Exercises: Section 4.4

4.4.1. Let YY have the following PMF:

yy12345
p(y)p(y)0.100.250.300.200.15

(a) Find E(Y)E(Y), E(Y2)E(Y^2), and V(Y)V(Y). (b) Find E(3Y2)E(3Y - 2) and V(3Y2)V(3Y - 2). (c) Find E(Y22Y+1)E(Y^2 - 2Y + 1). (Hint: note that Y22Y+1=(Y1)2Y^2 - 2Y + 1 = (Y-1)^2.)

4.4.2. A parking garage charges $5 per hour. The number of hours a randomly selected car stays in the garage, YY, has the distribution:

yy (hours)12345
p(y)p(y)0.200.300.250.150.10

(a) Find the expected parking revenue per car. (b) Find the variance and standard deviation of parking revenue per car. (c) The garage has 50 spots. If all spots are occupied by independent cars, what is the expected total revenue from all 50 cars?

4.4.3. A travel agency offers trip insurance that costs $120. The coverage pays out $0, $500, $2,000, or $8,000 depending on the severity of a trip disruption, with probabilities 0.85, 0.08, 0.05, and 0.02, respectively. Find the expected payout and determine whether the insurance is a “good deal” for the buyer (i.e., whether the expected payout exceeds the premium).

4.4.4. Let YY be a random variable with E(Y)=10E(Y) = 10 and V(Y)=4V(Y) = 4. Without knowing the distribution of YY, find:

(a) E(2Y+3)E(2Y + 3) (b) V(2Y+3)V(2Y + 3) (c) E(Y2)E(Y^2) (d) E[(Y10)2]E[(Y - 10)^2]

4.4.5. Prove that for any random variable YY with mean μ\mu, E[(Ya)2]E[(Y - a)^2] is minimized when a=μa = \mu. (Hint: expand (Ya)2=(Yμ+μa)2(Y - a)^2 = (Y - \mu + \mu - a)^2 and use properties of expectation.)


54.5 The Binomial Distribution

5.1The Bernoulli Trial

Before studying the Binomial, we need its building block: the Bernoulli trial.

The mean and variance of a Bernoulli random variable are computed step by step:

Mean:

E(X)=x=01xp(x)=0P(X=0)+1P(X=1)=0(1p)+1p=p.E(X) = \sum_{x=0}^{1} x \cdot p(x) = 0 \cdot P(X = 0) + 1 \cdot P(X = 1) = 0 \cdot (1-p) + 1 \cdot p = p.

Variance: First find E(X2)E(X^2). Since XX only takes values 0 and 1, and 02=00^2 = 0 and 12=11^2 = 1:

E(X2)=02(1p)+12p=p.E(X^2) = 0^2 \cdot (1-p) + 1^2 \cdot p = p.

Notice that E(X2)=E(X)=pE(X^2) = E(X) = p for the Bernoulli — this is a special coincidence because X2=XX^2 = X when XX is 0 or 1. Now apply the variance shortcut:

V(X)=E(X2)[E(X)]2=pp2=p(1p)=pq.V(X) = E(X^2) - [E(X)]^2 = p - p^2 = p(1 - p) = pq.

A Bernoulli trial is a single coin flip (possibly unfair). The Binomial distribution counts the number of “heads” in nn such flips.

5.2The Binomial Experiment

Important: The label “success” does not mean “good.” If we are counting defective items, a defective is a “success” in the Binomial sense. It is merely the outcome we are counting.

5.3Deriving the Binomial PMF

To find P(Y=y)P(Y = y), we count the sample points that result in exactly yy successes.

Each outcome of the experiment is an nn-tuple of SS’s and FF’s. A specific nn-tuple with yy successes and nyn - y failures — for example, SSSyFFFny\underbrace{SS \cdots S}_{y} \underbrace{FF \cdots F}_{n-y} — has probability:

pppyqqqny=pyqny\underbrace{p \cdot p \cdots p}_{y} \cdot \underbrace{q \cdot q \cdots q}_{n-y} = p^y q^{n-y}

by independence. Every nn-tuple with exactly yy successes has this same probability, regardless of where the successes appear.

How many such nn-tuples are there? We must choose which yy of the nn positions are successes. By the combinations formula from Chapter 2, there are C(n,y)=n!y!(ny)!C(n, y) = \frac{n!}{y!(n-y)!} ways.

Multiplying the number of nn-tuples by the probability of each:

5.4Mean and Variance of the Binomial

The results are elegant: the mean is npnp (on average, the fraction pp of nn trials are successes), and the variance is npqnpq. Notice that the variance is maximized when p=0.5p = 0.5 (maximum uncertainty per trial).

5.5Seeing It in R

#| label: binomial-sim
#| fig-cap: "Binomial PMF for Y ~ Bin(15, 0.4)"

# Theoretical PMF
n <- 15; p <- 0.4
y_vals <- 0:n
pmf_theory <- dbinom(y_vals, n, p)

# Simulation
set.seed(99)
n_sim <- 50000
Y_sim <- rbinom(n_sim, n, p)

par(mfrow = c(1, 2))

# Theoretical PMF
barplot(pmf_theory, names.arg = y_vals,
        main = paste0("Theoretical: Bin(", n, ", ", p, ")"),
        xlab = "y", ylab = "p(y)",
        col = "steelblue", border = "white")

# Simulated histogram (relative frequency)
barplot(table(Y_sim) / n_sim,
        main = paste0("Simulated (", format(n_sim, big.mark = ","), " repetitions)"),
        xlab = "y", ylab = "Relative Frequency",
        col = "coral", border = "white")

par(mfrow = c(1, 1))

# Verify mean and variance
cat("Theoretical: E(Y) =", n * p, " V(Y) =", n * p * (1 - p), "\n")
cat("Simulated:   E(Y) =", round(mean(Y_sim), 3),
    " V(Y) =", round(var(Y_sim), 3), "\n")

Key R functions for the Binomial:

FunctionWhat it computes
dbinom(y, n, p)P(Y=y)P(Y = y) — the PMF
pbinom(y, n, p)P(Yy)P(Y \leq y) — the CDF
rbinom(nsim, n, p)Simulate nsim values from Bin(n,p)\text{Bin}(n, p)


5.6Exercises: Section 4.5

4.5.1. A ride-sharing app shows that 75% of ride requests during rush hour are accepted by drivers within 2 minutes. If 20 ride requests come in during a rush hour window:

(a) What is the probability that exactly 16 are accepted within 2 minutes? (b) What is the probability that at least 18 are accepted within 2 minutes? (c) Find the expected number and standard deviation of requests accepted within 2 minutes.

4.5.2. In a manufacturing process, each item independently has a 3% probability of being defective. A batch of 25 items is produced.

(a) Find the probability that the batch contains no defective items. (b) Find the probability that the batch contains more than 2 defective items. (c) The manufacturer rejects a batch if it contains 3 or more defectives. What is the probability that a batch is rejected?

4.5.3. A multiple-choice exam has 30 questions, each with 4 options (one correct). A student who guesses on every question can be modeled as a Binomial experiment with p=0.25p = 0.25.

(a) Find the expected number of correct answers. (b) Find the standard deviation. (c) Find P(Y10)P(Y \geq 10) using R (command: 1 - pbinom(9, 30, 0.25)). Would you consider 10 or more correct answers “surprisingly good” for a pure guesser?

4.5.4. A certain genetic marker is present in 15% of a large population. In a sample of 12 randomly selected individuals:

(a) Find P(Y=0)P(Y = 0), P(Y=1)P(Y = 1), and P(Y=2)P(Y = 2). (b) Find P(Y4)P(Y \geq 4). (c) Compute μ\mu and σ\sigma.

4.5.5. A basketball player has a free-throw percentage of 80%. She shoots 6 free throws in a game.

(a) Find the probability that she makes all 6. (b) Find the probability that she misses at most 1. (c) The player claims she is “in the zone” if she makes at least 5 of 6. What is the probability of this happening even without any hot streak (i.e., purely by chance with p=0.80p = 0.80)?

4.5.6. (Proof exercise) Show that the Binomial PMF sums to 1 by using the Binomial Theorem: (p+q)n=y=0nC(n,y)pyqny(p + q)^n = \sum_{y=0}^{n} C(n,y) p^y q^{n-y}, with q=1pq = 1 - p.


64.6 The Geometric Distribution

6.1Derivation

Consider an experiment where independent Bernoulli trials (each with success probability pp) are performed sequentially until the first success occurs. Let YY = the trial number on which the first success happens.

For Y=yY = y, we need y1y - 1 failures followed by 1 success:

P(Y=y)=qqqy1p=qy1p.P(Y = y) = \underbrace{q \cdot q \cdots q}_{y-1} \cdot p = q^{y-1} p.

Note on parameterization. Some textbooks (and R) define the Geometric as the number of failures before the first success, so YY starts at 0. We follow the Wackerly convention where YY = the trial number of the first success, so YY starts at 1. When using R’s dgeom and pgeom, adjust accordingly: R’s dgeom(k, p) gives P(X=k)P(X = k) where XX = number of failures, so P(Y=y)=P(Y = y) = dgeom(y-1, p).

The probabilities sum to 1 because this is a geometric series:

y=1qy1p=py=1qy1=p11q=p1p=1.\sum_{y=1}^{\infty} q^{y-1} p = p \sum_{y=1}^{\infty} q^{y-1} = p \cdot \frac{1}{1-q} = p \cdot \frac{1}{p} = 1.

6.2Mean and Variance

Before deriving the mean and variance, let us recall a critical calculus tool that students often forget.

The mean makes intuitive sense: if the probability of success on each trial is p=0.20p = 0.20, then on average you need 1/0.20=51/0.20 = 5 trials. A lower success probability means a longer expected wait.

6.3The Memoryless Property

The Geometric distribution has a remarkable and counterintuitive property: it has no memory.

P(Y>s+tY>s)=P(Y>t),for all s,t0.P(Y > s + t \mid Y > s) = P(Y > t), \qquad \text{for all } s, t \geq 0.

In words: given that you have already failed ss times, the probability of needing more than tt additional trials is the same as if you were starting fresh. The past failures provide no information about how much longer you will wait.

Proof. Using P(Y>k)=qkP(Y > k) = q^k:

P(Y>s+tY>s)=P(Y>s+t)P(Y>s)=qs+tqs=qt=P(Y>t).P(Y > s + t \mid Y > s) = \frac{P(Y > s + t)}{P(Y > s)} = \frac{q^{s+t}}{q^s} = q^t = P(Y > t). \quad \blacksquare


6.4Exercises: Section 4.6

4.6.1. A student tries to log into a university portal, but keeps mistyping the CAPTCHA. Each attempt independently has a 70% chance of success. Let YY be the attempt on which the student first succeeds.

(a) Find P(Y=1)P(Y = 1), P(Y=2)P(Y = 2), and P(Y=3)P(Y = 3). (b) Find P(Y>5)P(Y > 5). (c) Find E(Y)E(Y) and σ\sigma.

4.6.2. A fisherman catches a fish on any given cast with probability 0.10. Casts are independent.

(a) What is the probability that the first fish is caught on the 7th cast? (b) What is the expected number of casts until the first fish? (c) If the fisherman has already made 12 unsuccessful casts, what is the probability he catches a fish within the next 3 casts? (Use the memoryless property.)

4.6.3. Suppose YGeom(p)Y \sim \text{Geom}(p).

(a) Show that P(Y>k)=qkP(Y > k) = q^k for k=0,1,2,k = 0, 1, 2, \ldots. (b) Use part (a) to derive the CDF F(y)=P(Yy)=1qyF(y) = P(Y \leq y) = 1 - q^y for positive integers yy. (c) Find the median of YY — the smallest value mm such that F(m)0.5F(m) \geq 0.5.

4.6.4. An online retailer finds that 12% of visitors to a product page make a purchase. If visitors arrive independently, what is the probability that the 1st purchase occurs within the first 5 visitors? What is the probability it takes more than 20 visitors?


74.7 The Negative Binomial Distribution

7.1Derivation

We perform independent Bernoulli trials with success probability pp until we observe the rr-th success. Let YY = the trial number on which the rr-th success occurs. For Y=yY = y, we need:

The number of ways to arrange r1r - 1 successes in y1y - 1 trials is C(y1,r1)C(y-1, r-1). The probability of any such arrangement followed by a success is pr1qyrp=prqyrp^{r-1} q^{y-r} \cdot p = p^r q^{y-r}.

Why C(y1,r1)C(y-1, r-1) and not C(y,r)C(y, r)? Because the rr-th success is fixed at position yy — it must be the last trial. We are only choosing where the first r1r-1 successes go among the first y1y-1 positions. This is the key insight that students often miss.

Relationship to Geometric: When r=1r = 1, C(y1,0)=1C(y-1, 0) = 1 and the Negative Binomial reduces to p(y)=pqy1p(y) = p \cdot q^{y-1}, which is exactly the Geometric distribution. The Geometric is a special case of the Negative Binomial.

These results make intuitive sense: waiting for the rr-th success takes rr times as long on average as waiting for the first, and the total variability scales linearly with rr.

R functions for the Negative Binomial: R parameterizes using the number of failures, not the trial number. If YNegBin(r,p)Y \sim \text{NegBin}(r, p) in our notation, then the number of failures is YrY - r, and:

Our notationR command
P(Y=y)P(Y = y)dnbinom(y - r, r, p)
P(Yy)P(Y \leq y)pnbinom(y - r, r, p)


7.2Exercises: Section 4.7

4.7.1. A sales representative makes cold calls with a 10% chance of making a sale on each call. She needs to make 4 sales today.

(a) What is the probability that her 4th sale comes on the 20th call? (b) How many calls should she expect to make? (c) What is the standard deviation of the number of calls?

4.7.2. In a game, a player rolls a fair die repeatedly until they roll three 6’s. Let YY be the total number of rolls needed.

(a) Find P(Y=5)P(Y = 5). (b) Find E(Y)E(Y).

4.7.3. Show that the Negative Binomial PMF reduces to the Geometric PMF when r=1r = 1.


84.8 The Hypergeometric Distribution

8.1The Setup

We have a population of NN items, of which rr are “successes” and NrN - r are “failures.” We draw a sample of nn items without replacement. Let YY = the number of successes in the sample.

The probability of getting exactly yy successes is found by counting:

8.2Mean, Variance, and the Finite Population Correction

The mean nr/Nnr/N is identical to the Binomial mean npnp with p=r/Np = r/N — on average, the fraction of successes in the sample matches the fraction in the population.

The variance, however, has an extra factor: NnN1\frac{N-n}{N-1}, called the finite population correction (FPC). This factor is always less than or equal to 1, so the Hypergeometric variance is always less than or equal to the corresponding Binomial variance npqnpq. Sampling without replacement reduces variability because drawing successes early makes failures more likely later (and vice versa).

When NN is much larger than nn (say, n<0.05Nn < 0.05N), the FPC is close to 1, and the Hypergeometric is well approximated by a Binomial with p=r/Np = r/N. Removing a few items from a huge population barely changes the composition.

8.3Seeing It in R

#| label: hypergeometric-comparison
#| fig-cap: "Hypergeometric vs Binomial approximation"

# Scholarship example: N=20, r=8, n=6
N <- 20; r_succ <- 8; n <- 6
y_vals <- 0:n
p_hyper <- dhyper(y_vals, r_succ, N - r_succ, n)
p_binom <- dbinom(y_vals, n, r_succ / N)

# Side-by-side comparison
barplot(rbind(p_hyper, p_binom), beside = TRUE,
        names.arg = y_vals,
        col = c("steelblue", "coral"),
        main = "Hypergeometric vs Binomial (N=20, small population)",
        xlab = "y", ylab = "P(Y = y)",
        legend.text = c("Hypergeometric", "Binomial approx"),
        args.legend = list(x = "topright"))

Key R functions: dhyper(y, r, N-r, n) gives P(Y=y)P(Y = y); phyper(y, r, N-r, n) gives P(Yy)P(Y \leq y).



8.4Exercises: Section 4.8

4.8.1. A jar contains 15 red marbles and 10 blue marbles. You draw 7 marbles without replacement.

(a) Find P(Y=3)P(Y = 3), where YY = number of red marbles drawn. (b) Find E(Y)E(Y) and V(Y)V(Y). (c) If the jar instead contained 1500 red and 1000 blue marbles and you drew 7, compute the Binomial approximation to P(Y=3)P(Y = 3) and compare to the exact Hypergeometric probability.

4.8.2. A box contains 30 USB drives, 6 of which are defective. An inspector randomly selects 5 drives for testing.

(a) Find the probability that the sample contains exactly 1 defective. (b) Find the probability that the sample contains no defectives. (c) Find the probability that the sample contains at least 2 defectives.

4.8.3. A hiring committee reviews 25 applicants, of whom 10 have graduate degrees. They randomly select 8 for interviews. Find the expected number with graduate degrees and the standard deviation. Compare the Hypergeometric standard deviation to the Binomial approximation npq\sqrt{npq}.

4.8.4. (Proof exercise) Show that when NN \to \infty with r/N=pr/N = p held constant, the Hypergeometric PMF converges to the Binomial PMF C(n,y)py(1p)nyC(n,y) p^y (1-p)^{n-y}. (Hint: use the fact that C(r,y)/C(N,y)pyC(r, y)/C(N, y) \to p^y as N,rN, r \to \infty with r/Npr/N \to p.)


94.9 The Poisson Distribution

9.1The Poisson Model

The Poisson distribution applies when:

  1. Events occur independently — one event does not make another more or less likely.

  2. Events occur at a constant average rate λ\lambda per interval.

  3. In a sufficiently small sub-interval, at most one event can occur (no simultaneous events).

The probabilities sum to 1 because of the Taylor series for eλe^{\lambda}:

y=0λyy!eλ=eλy=0λyy!=eλeλ=1.\sum_{y=0}^{\infty} \frac{\lambda^y}{y!} e^{-\lambda} = e^{-\lambda} \sum_{y=0}^{\infty} \frac{\lambda^y}{y!} = e^{-\lambda} \cdot e^{\lambda} = 1.

The elegance of the Poisson: the mean and variance are both equal to λ\lambda. If you observe data where the sample mean and sample variance are approximately equal, the Poisson may be a good model.

9.2The Poisson Approximation to the Binomial

The Poisson distribution arises as a limit of the Binomial when nn is large, pp is small, and λ=np\lambda = np remains moderate. Intuitively: if you have many trials, each with a tiny probability of success, the count of successes is approximately Poisson.

Rule of thumb: The Poisson approximation to the Binomial is good when n20n \geq 20 and p0.05p \leq 0.05, with λ=np\lambda = np.

9.3Seeing It in R

#| label: poisson-sim
#| fig-cap: "Poisson distribution and simulation for delivery orders"

lambda <- 6
y_vals <- 0:15
pmf_theory <- dpois(y_vals, lambda)

# Simulation
set.seed(77)
Y_sim <- rpois(50000, lambda)

par(mfrow = c(1, 2))
barplot(pmf_theory, names.arg = y_vals,
        main = paste0("Theoretical: Pois(", lambda, ")"),
        xlab = "y (orders)", ylab = "P(Y = y)",
        col = "steelblue", border = "white")
barplot(table(factor(Y_sim, levels = y_vals)) / length(Y_sim),
        main = "Simulated (50,000 hours)",
        xlab = "y (orders)", ylab = "Relative Frequency",
        col = "coral", border = "white")
par(mfrow = c(1, 1))

Key R functions: dpois(y, lambda), ppois(y, lambda), rpois(nsim, lambda).



9.4Exercises: Section 4.9

4.9.1. A hospital emergency department sees an average of 8 patients per hour overnight. Assume arrivals follow a Poisson process.

(a) Find the probability of exactly 5 arrivals in a given hour. (b) Find the probability of 12 or more arrivals in an hour. (c) Find the probability of no arrivals in a 15-minute window. (d) Find the expected number and standard deviation of arrivals per hour.

4.9.2. The number of typos per page in a 300-page manuscript follows a Poisson distribution with λ=0.8\lambda = 0.8 typos per page.

(a) Find the probability that a randomly selected page has no typos. (b) Find the probability that a page has 3 or more typos. (c) In a 5-page section, what is the expected number of typos? What distribution does the total follow?

4.9.3. (Poisson approximation) A large website has 50,000 daily visitors, each with a 0.00004 probability of encountering a critical error.

(a) Identify nn and pp for the Binomial model. (b) Compute λ=np\lambda = np and use the Poisson approximation to find P(Y=0)P(Y = 0), P(Y=1)P(Y = 1), and P(Y3)P(Y \geq 3).

4.9.4. Earthquakes of magnitude 6.0 or greater occur in a certain region at an average rate of 2.5 per year. Assuming a Poisson process:

(a) Find the probability of no such earthquakes in a given year. (b) Find the probability of 5 or more in a given year. (c) Find the probability of no such earthquakes in a 6-month period.

4.9.5. (Proof exercise) Show that for the Poisson distribution, E[Y(Y1)]=λ2E[Y(Y-1)] = \lambda^2, and use this to confirm that V(Y)=λV(Y) = \lambda.


104.10 Moments and Moment-Generating Functions

10.1Moments

In particular, μ1=E(Y)=μ\mu'_1 = E(Y) = \mu (the mean), and μ2=V(Y)=σ2\mu_2 = V(Y) = \sigma^2 (the variance). Higher moments capture other features of the distribution: the third central moment relates to skewness (asymmetry), and the fourth to kurtosis (tail heaviness).

10.2The Moment-Generating Function

Why does this “generate” moments? Expand etYe^{tY} using the Taylor series for exe^x with x=tYx = tY:

m(t)=E[1+tY+(tY)22!+(tY)33!+]=1+tE(Y)+t22!E(Y2)+t33!E(Y3)+m(t) = E\left[1 + tY + \frac{(tY)^2}{2!} + \frac{(tY)^3}{3!} + \cdots\right] = 1 + t \cdot E(Y) + \frac{t^2}{2!} E(Y^2) + \frac{t^3}{3!} E(Y^3) + \cdots

The kk-th moment μk=E(Yk)\mu'_k = E(Y^k) appears as the coefficient of tk/k!t^k / k!. To extract it, differentiate kk times and set t=0t = 0:

10.3Computing MGFs and Identifying Distributions

Summary of MGFs for named distributions:

DistributionMGF m(t)m(t)
Bernoulli(p)(p)pet+qpe^t + q
Binomial(n,p)(n, p)(pet+q)n(pe^t + q)^n
Geometric(p)(p)pet1qet\dfrac{pe^t}{1 - qe^t}, for t<lnqt < -\ln q
Poisson(λ)(\lambda)eλ(et1)e^{\lambda(e^t - 1)}


10.4Exercises: Section 4.10

4.10.1. Derive the MGF of a Bernoulli(p)(p) random variable directly from the definition.

4.10.2. A random variable ZZ has MGF m(t)=0.4et10.6etm(t) = \dfrac{0.4 e^t}{1 - 0.6 e^t} for t<ln(0.6)t < -\ln(0.6). Identify the distribution of ZZ and find E(Z)E(Z) and V(Z)V(Z).

4.10.3. Use the MGF of the Binomial distribution m(t)=(pet+q)nm(t) = (pe^t + q)^n to derive E(Y)=npE(Y) = np and V(Y)=npqV(Y) = npq by computing m(0)m'(0) and m(0)m''(0).

4.10.4. A random variable XX has MGF m(t)=(0.5et+0.5)12m(t) = (0.5e^t + 0.5)^{12}. Find P(X3)P(X \leq 3) using R.


114.11 Tchebysheff’s Theorem

11.1Markov’s Inequality (The Foundation)

Before proving Tchebysheff’s theorem, we establish a simpler but more general result that it builds on.

Why Markov matters: It says a non-negative random variable cannot frequently be much larger than its mean. For example, if E(Y)=10E(Y) = 10, then P(Y100)10/100=0.10P(Y \geq 100) \leq 10/100 = 0.10. The bound is often loose, but it works with only the mean — no variance needed.

From Markov to Tchebysheff: Tchebysheff’s theorem is simply Markov’s inequality applied to the non-negative random variable (Yμ)2(Y - \mu)^2 with a=k2σ2a = k^2\sigma^2. This gives us the tighter bound that uses variance information.

What this says in plain language: At least 11/k21 - 1/k^2 of the probability lies within kk standard deviations of the mean.

kkAt least this fraction is within μ±kσ\mu \pm k\sigma
211/4=75%1 - 1/4 = 75\%
311/988.9%1 - 1/9 \approx 88.9\%
411/16=93.75%1 - 1/16 = 93.75\%
511/25=96%1 - 1/25 = 96\%

Two critical observations:

  1. It works for any distribution. No assumptions about shape, symmetry, or named families. This is its power.

  2. It is conservative. For most distributions, the actual probability within μ±2σ\mu \pm 2\sigma is much higher than 75%. For a normal distribution, it is 95.4%. Tchebysheff gives a guaranteed floor, not an exact answer.



11.2Exercises: Section 4.11

4.11.1. A random variable YY has mean μ=25\mu = 25 and standard deviation σ=4\sigma = 4.

(a) Use Tchebysheff’s theorem to find a lower bound for P(17<Y<33)P(17 < Y < 33). (b) Find the value CC such that P(Y25C)0.01P(|Y - 25| \geq C) \leq 0.01.

4.11.2. The number of daily transactions at an ATM has μ=120\mu = 120 and σ=18\sigma = 18, with unknown distribution. The bank wants at least 90% of days to fall within the staffing plan’s capacity range. What range (centered at μ\mu) guarantees this?

4.11.3. YBin(100,0.5)Y \sim \text{Bin}(100, 0.5), so μ=50\mu = 50 and σ=5\sigma = 5. Use Tchebysheff to find a lower bound for P(40<Y<60)P(40 < Y < 60). Then compute the exact probability using R (pbinom(59, 100, 0.5) - pbinom(40, 100, 0.5)) and compare. How conservative is the bound?


124.12 The Poisson Limit Theorem ★

This section is optional enrichment. It provides the formal proof that the Poisson distribution arises as a limit of the Binomial. Your instructor may choose to skip this section.

Why this matters: This theorem explains where the Poisson distribution comes from. When you have many opportunities for a rare event (large nn, small pp), the Poisson emerges naturally. This is why it shows up in so many seemingly unrelated contexts — typos, radioactive decay, server requests, disease cases — all are situations with many “trials” and small individual probabilities.


134.13 Classic Problems ★

This section is optional enrichment. It showcases three classic probability problems that illustrate the power of expected value and indicator random variables. Your instructor may assign selected problems or skip this section entirely.

13.1The Matching Problem (Montmort, 1708)

A professor returns nn exams to nn students completely at random. What is the expected number of students who receive their own exam?

Solution using indicator variables. Let Ij=1I_j = 1 if student jj gets their own exam, and Ij=0I_j = 0 otherwise. The total number of matches is Y=I1+I2++InY = I_1 + I_2 + \cdots + I_n.

Each student has a 1/n1/n chance of getting their own exam: E(Ij)=1/nE(I_j) = 1/n.

By linearity of expectation (even though the IjI_j’s are dependent!):

E(Y)=E(I1)+E(I2)++E(In)=n1n=1.E(Y) = E(I_1) + E(I_2) + \cdots + E(I_n) = n \cdot \frac{1}{n} = 1.

The surprising result: No matter how many students there are — 5 or 500 or 5 million — the expected number of matches is always exactly 1. Furthermore, for large nn, the number of matches is approximately Pois(1)\text{Pois}(1), so the probability of zero matches approaches e10.368e^{-1} \approx 0.368.

13.2The Coupon Collector Problem

A cereal company puts one of nn different toy figurines in each box, chosen uniformly at random. How many boxes must you buy, on average, to collect all nn figurines?

Solution using Geometric decomposition. After collecting kk distinct figurines, the probability that the next box contains a new one is pk=(nk)/np_k = (n - k)/n. The number of additional boxes needed to get the next new figurine is Geom(pk)\text{Geom}(p_k) with mean n/(nk)n/(n - k).

The total number of boxes is T=T0+T1++Tn1T = T_0 + T_1 + \cdots + T_{n-1} where TkGeom((nk)/n)T_k \sim \text{Geom}((n-k)/n).

By linearity:

E(T)=nn+nn1+nn2++n1=n(1+12+13++1n)=nHnE(T) = \frac{n}{n} + \frac{n}{n-1} + \frac{n}{n-2} + \cdots + \frac{n}{1} = n\left(1 + \frac{1}{2} + \frac{1}{3} + \cdots + \frac{1}{n}\right) = n \cdot H_n

where Hn=k=1n1/kH_n = \sum_{k=1}^{n} 1/k is the nn-th harmonic number. For large nn, Hnlnn+0.5772H_n \approx \ln n + 0.5772 (Euler’s constant).

Example: With n=50n = 50 figurines, E(T)=50H5050×4.499225E(T) = 50 \cdot H_{50} \approx 50 \times 4.499 \approx 225 boxes. You need to buy roughly 4.5 times as many boxes as there are figurines!

13.3The St. Petersburg Paradox (Bernoulli, 1738)

A casino offers this game: flip a fair coin repeatedly until the first heads appears on toss kk. You win 2k2^k dollars. How much should you pay to play?

Expected value calculation: YY = winnings. P(Y=2k)=(1/2)kP(Y = 2^k) = (1/2)^k for k=1,2,3,k = 1, 2, 3, \ldots

E(Y)=k=12k(12)k=k=11=.E(Y) = \sum_{k=1}^{\infty} 2^k \cdot \left(\frac{1}{2}\right)^k = \sum_{k=1}^{\infty} 1 = \infty.

The expected value is infinite! By naive expected-value reasoning, you should be willing to pay any finite amount to play. Yet no rational person would pay even $100.

Why this matters: The St. Petersburg Paradox shows that expected value alone does not capture everything about a decision. It motivated Daniel Bernoulli to propose expected utility (using E[log(wealth)]E[\log(\text{wealth})] instead of E[wealth]E[\text{wealth}]) — one of the foundational ideas of economics and decision theory. It is a powerful reminder that while expected value is an essential tool, it has limits.


14Chapter Summary

This chapter introduced discrete random variables — functions that assign numerical values to the outcomes of random experiments — and developed the complete toolkit for describing their probability behavior.

Key takeaways:

  1. A random variable is a function from the sample space to the real numbers. It translates outcomes into numbers we can compute with.

  2. The probability mass function (PMF) p(y)=P(Y=y)p(y) = P(Y = y) provides the probability of each value. The cumulative distribution function (CDF) F(y)=P(Yy)F(y) = P(Y \leq y) accumulates probabilities from left to right.

  3. The expected value E(Y)=yp(y)E(Y) = \sum y \cdot p(y) is the long-run average — the center of gravity of the distribution. More generally, E[g(Y)]=g(y)p(y)E[g(Y)] = \sum g(y) \cdot p(y).

  4. The variance V(Y)=E(Y2)[E(Y)]2V(Y) = E(Y^2) - [E(Y)]^2 measures spread. The standard deviation σ=V(Y)\sigma = \sqrt{V(Y)} has the same units as YY.

  5. Five named distributions capture common experimental patterns. The distribution you choose depends on the story of the experiment:

DistributionThe StoryPMFE(Y)E(Y)V(Y)V(Y)
Bernoulli(p)(p)Single trial, two outcomespyq1yp^y q^{1-y}pppqpq
Binomial(n,p)(n,p)nn trials, count successesC(n,y)pyqnyC(n,y) p^y q^{n-y}npnpnpqnpq
Geometric(p)(p)Trials until 1st successqy1pq^{y-1}p1/p1/pq/p2q/p^2
Neg. Binomial(r,p)(r,p)Trials until rr-th successC(y ⁣ ⁣1,r ⁣ ⁣1)prqyrC(y\!-\!1, r\!-\!1)p^r q^{y-r}r/pr/prq/p2rq/p^2
Hypergeometric(N,r,n)(N,r,n)nn draws without replacementC(r,y)C(Nr,ny)C(N,n)\frac{C(r,y)C(N-r,n-y)}{C(N,n)}nr/Nnr/NnrNNrNNnN1n\frac{r}{N}\frac{N-r}{N}\frac{N-n}{N-1}
Poisson(λ)(\lambda)Events in a fixed intervalλyy!eλ\frac{\lambda^y}{y!}e^{-\lambda}λ\lambdaλ\lambda
  1. Moment-generating functions m(t)=E(etY)m(t) = E(e^{tY}) uniquely determine distributions and generate moments via μk=m(k)(0)\mu'_k = m^{(k)}(0).

  2. Tchebysheff’s theorem provides universal probability bounds: at least 11/k21 - 1/k^2 of the probability is within kk standard deviations of the mean, for any distribution.

14.1The Distribution Family Tree

Understanding the relationships between distributions is as important as knowing the formulas:

14.2Which Distribution? A Selection Guide

When faced with a problem, ask these questions in order:

QuestionIf YESIf NO
Fixed number of trials nn?Go to next rowGo to Geometric/NegBin/Poisson
Sampling with replacement (or population ≫ sample)?BinomialHypergeometric
Counting events in a time/space interval?PoissonGo to next row
Waiting for the 1st success?GeometricGo to next row
Waiting for the rr-th success?Negative BinomialRe-read the problem!

14.3Key R Functions

DistributionP(Y=y)P(Y = y)P(Yy)P(Y \leq y)Simulate
Binomialdbinom(y, n, p)pbinom(y, n, p)rbinom(nsim, n, p)
Geometricdgeom(y-1, p)pgeom(y-1, p)rgeom(nsim, p) + 1
Neg. Binomialdnbinom(y-r, r, p)pnbinom(y-r, r, p)rnbinom(nsim, r, p) + r
Hypergeometricdhyper(y, r, N-r, n)phyper(y, r, N-r, n)rhyper(nsim, r, N-r, n)
Poissondpois(y, lambda)ppois(y, lambda)rpois(nsim, lambda)

Note: R parameterizes the Geometric and Negative Binomial by the number of failures, not the trial number. Adjust accordingly (see the notes in Sections 4.6 and 4.7).




15Chapter Refresh Homework

The following problems span the entire chapter. They are designed to test your ability to identify the correct distribution, compute by hand, verify in R, and interpret results in context.

4.R.1. A campus IT department records the number of help desk tickets submitted per hour. The distribution is:

yy012345
p(y)p(y)0.080.180.280.220.140.10

(a) Find E(Y)E(Y), E(Y2)E(Y^2), V(Y)V(Y), and σ\sigma. (b) Each ticket takes an average of 15 minutes to resolve. Find the expected total resolution time per hour and its standard deviation. (c) Use Tchebysheff’s theorem to find an interval that contains at least 75% of hourly ticket counts.

4.R.2. A pharmaceutical company tests a new antibiotic. Each patient independently has a 65% probability of showing significant improvement. Fifteen patients are enrolled in the trial.

(a) What distribution does YY (the number who improve) follow? State the parameters. (b) Find P(Y=10)P(Y = 10) and P(Y12)P(Y \geq 12). (c) Find the expected number who improve and the standard deviation. (d) If fewer than 8 patients improve, the drug is deemed ineffective. Find this probability.

4.R.3. A venture capital firm reviews startup pitches. Each pitch independently has a 12% chance of receiving funding. The firm reviews pitches until it funds its 3rd startup.

(a) What distribution does YY (the number of pitches reviewed) follow? (b) Find the expected number of pitches and the standard deviation. (c) Find the probability that the 3rd funded startup is found on exactly the 15th pitch.

4.R.4. A box contains 40 light bulbs, 8 of which are defective. An inspector randomly selects 6 bulbs for testing.

(a) What distribution does YY (the number of defectives in the sample) follow? Why not Binomial? (b) Find P(Y=0)P(Y = 0), P(Y=1)P(Y = 1), and P(Y3)P(Y \geq 3). (c) Find E(Y)E(Y) and V(Y)V(Y). Compare the Hypergeometric variance to the Binomial approximation npqnpq with p=8/40p = 8/40.

4.R.5. A regional earthquake monitoring station records an average of 3.2 earthquakes of magnitude 4.0+ per month.

(a) What distribution is appropriate? State the parameter. (b) Find the probability of exactly 5 earthquakes in a given month. (c) Find the probability of no earthquakes in a 2-week period. (d) Find the probability of 8 or more earthquakes in a 2-month period.

4.R.6. A random variable XX has MGF m(t)=e7(et1)m(t) = e^{7(e^t - 1)}.

(a) Identify the distribution of XX. (b) Find E(X)E(X) and V(X)V(X) directly from the distribution. (c) Verify E(X)E(X) by computing m(0)m'(0).

4.R.7. An online retailer finds that 8% of packages are delivered late. In a random sample of 30 packages:

(a) Find the probability that exactly 3 are delivered late. (b) Find the probability that fewer than 2 are delivered late. (c) Use the Poisson approximation (with λ=np\lambda = np) to approximate P(Y=3)P(Y = 3) and compare to the exact Binomial answer from part (a).

4.R.8. A student has a 0.40 probability of scoring a bullseye on each dart throw. Throws are independent.

(a) What is the probability that the student’s first bullseye comes on the 5th throw? (b) What is the expected number of throws until the first bullseye? (c) Given that the first 3 throws were not bullseyes, what is the probability that the first bullseye comes on throw 6 or later? (Use the memoryless property.)

4.R.9. A random variable YY has mean 50 and standard deviation 6, but its distribution is unknown.

(a) Use Tchebysheff’s theorem to bound P(38<Y<62)P(38 < Y < 62). (b) Find CC such that P(Y50C)0.05P(|Y - 50| \geq C) \leq 0.05. (c) If you later learn that YY is approximately normally distributed, how does your answer to (a) change?

4.R.10. (Distribution identification) For each scenario below, identify the appropriate distribution and state its parameters. Do not compute probabilities — just identify and justify.

(a) A roulette wheel has 38 slots (18 red, 18 black, 2 green). A gambler bets on red 20 times. YY = number of wins. (b) A committee of 5 is randomly selected from a group of 10 men and 8 women. YY = number of women on the committee. (c) A website receives an average of 200 hits per minute. YY = number of hits in a 30-second window. (d) A telemarketer calls potential customers. Each call independently has a 3% success rate. YY = the call number on which the 2nd sale occurs. (e) A student retakes a certification exam repeatedly until passing. Each attempt has a 55% pass rate. YY = the attempt on which the student first passes.

4.R.11. (Proof) Let YY be a discrete random variable with E(Y)=μE(Y) = \mu and V(Y)=σ2V(Y) = \sigma^2. Prove that E[(Ya)2]E[(Y - a)^2] is minimized when a=μa = \mu. Interpret this result in plain language.

4.R.12. (Comprehensive R exercise) Using R, generate 100,000 simulated values from each of the following distributions. For each, compute the sample mean and sample variance and compare to the theoretical values.

(a) Bin(20,0.35)\text{Bin}(20, 0.35) (b) Pois(7.5)\text{Pois}(7.5) (c) Geom(0.15)\text{Geom}(0.15)

Provide your R code and a brief summary of what you observe.