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.


1What Is This Book About?

Let’s start with the simplest possible answer:

This book teaches you the mathematical rules that govern randomness.

That sounds abstract, so here’s what it means in practice. By the end of this book, you’ll be able to answer questions like these:

These aren’t toy questions. They are the foundational calculations behind medical diagnostics, insurance pricing, quality control in manufacturing, machine learning algorithms, financial risk models, sports analytics, and criminal justice.

This book gives you the mathematical machinery to solve all of them.

2Probability Is Everywhere

Before we dive into mathematics, let’s look at where probability theory actually shows up in the real world. The point of this section is to convince you that what you’re about to learn is not just a math course requirement — it’s a set of tools that professional adults use every single day.

2.1Medicine

A doctor orders a blood test for a rare disease. The test is 99% accurate, meaning it correctly identifies sick patients 99% of the time. But here’s the problem: among healthy patients, it incorrectly returns a positive result 2% of the time (a false positive). The disease affects 1 in 10,000 people. If a patient tests positive, what’s the probability they actually have the disease?

Your gut says “about 99%.” The real answer? About 0.5%. Yes — less than 1%. Understanding why requires Bayes’ Rule, which we’ll derive in Chapter 3.

2.2Sports

A basketball player shoots free throws at 80%. In a game, she takes 15 free throws. What’s the probability she makes at least 13? This is a direct application of the binomial distribution (Chapter 4). Sports analytics teams use these exact calculations to evaluate player performance, build lineup models, and set game strategy.

2.3Finance

An options trader needs to estimate the probability that a stock price moves more than 5% in either direction over the next month. The price changes on any given day are approximately normally distributed. The probability comes from the normal distribution (Chapter 5), and the joint behavior of multiple assets involves multivariate distributions (Chapter 6).

2.4Weather Forecasting

When a meteorologist says “there is a 70% chance of rain tomorrow,” that number comes from probability models. The models combine information from atmospheric measurements, historical patterns, and satellite data using conditional probability and Bayesian updating (Chapter 3).

2.5Manufacturing and Quality Control

A factory produces microchips. On average, 3 defects occur per 1,000 chips. If a batch of 500 chips is inspected, what’s the probability of finding more than 5 defects? This is a textbook application of the Poisson distribution (Chapter 4). Quality engineers use this every day to decide whether to ship or hold production lots.

2.6Criminal Justice

DNA evidence is presented in court. “The probability of a random match is 1 in 10 million.” The prosecutor argues that the defendant is therefore almost certainly guilty. But this confuses P(evidence | innocent) with P(innocent | evidence) — a mistake so common it has a name: the prosecutor’s fallacy. Correcting this error requires Bayes’ Rule (Chapter 3).

2.7Insurance

An insurance company needs to set premiums for car insurance. They model the number of claims a policyholder will file per year using a Poisson distribution, and the dollar amount of each claim using a Gamma distribution (Chapters 4 and 5). The premiums are computed using expected values — a concept we’ll define precisely in Chapter 4.

2.8Machine Learning

Every machine learning algorithm — from logistic regression to neural networks — is built on probability. The training process maximizes the probability of the observed data given the model parameters. This is called maximum likelihood estimation, and the probability distributions it relies on are exactly the ones you’ll learn in Chapters 4 and 5.

2.9Gaming and Gambling

What’s the probability of being dealt a full house in poker? What’s the expected value of a lottery ticket? These are counting and expected value problems (Chapters 2 and 4). Casinos set their rules specifically so that the expected value favors the house — always.

2.10Epidemiology

During a disease outbreak, epidemiologists model the number of daily hospital admissions using count distributions. The number of new cases per day might follow a Poisson or negative binomial distribution (Chapter 4), and the time between cases follows a Gamma or exponential distribution (Chapter 5).

3How This Book Works

This book follows a three-step learning pipeline for every major concept:

3.1Step 1: See It

Before we define anything formally, we start with a simulation or a concrete example. We’ll run R code that generates random data and lets you observe the pattern before we prove it exists. This is the “ground up” philosophy — you see the phenomenon first, then we build the theory underneath it.

3.2Step 2: Prove It

After you’ve seen the pattern, we prove it rigorously. Every theorem in this book comes with a complete proof. We never write “it can be shown that” or “the proof is left as an exercise.” If a result is important enough to state, it’s important enough to prove. And every proof begins with a strategy note — one or two sentences explaining the approach before we dive into the details.

3.3Step 3: Simulate It

After the proof, we return to R. We write code that confirms the theoretical result empirically. You’ll see the numbers match. This closes the loop: observation → theory → verification.

4A Quick Review of the Basics

If you’ve taken an introductory statistics course, this section will be a refresher. If you haven’t, this section teaches you everything you need to know before Chapter 2. Either way, read it — the notation we establish here is used throughout the book.

4.1Individuals, Variables, Populations, and Samples

Every statistical investigation begins with the same six components. We use the acronym IVPPSS to remember them:

4.2Variable Types

Variables come in different flavors, and the type determines which probability models apply:

Why does this matter for probability? Discrete random variables get probability mass functions (Chapter 4). Continuous random variables get probability density functions (Chapter 5). The distinction is fundamental and runs through the entire book.

5Summarizing Data: Center and Spread

When we have a collection of numerical data, the two most important questions are: Where is the center? and How spread out are the values?

5.1The Sample Mean

Before we define the mean, let’s make sure the notation is solid. The formulas in this section — and throughout the book — use summation notation (Σ\Sigma), which is the discrete cousin of integration (\int). If you’re rusty on either, this box will save you time.

5.2The Sample Median

For the bass weights, we first sort the data:

3.6,3.8,4.2,4.7,5.1,5.3,5.5,6.03.6, \quad 3.8, \quad 4.2, \quad 4.7, \quad 5.1, \quad 5.3, \quad 5.5, \quad 6.0

With n=8n = 8 (even), the median is the average of the 4th and 5th values:

y~=4.7+5.12=4.9 pounds\tilde{y} = \frac{4.7 + 5.1}{2} = 4.9 \text{ pounds}

5.3The Sample Variance and Standard Deviation

The mean tells us where the center is. But two datasets can have the same mean and look completely different if one is tightly clustered and the other is spread out. We need a measure of spread.

5.4The Shortcut Formula for Variance

Computing variance with the definition is tedious. There’s a shortcut that’s faster for hand calculations:

5.5The Empirical Rule

How do we interpret the standard deviation? The Empirical Rule gives a powerful answer for data that are approximately bell-shaped (symmetric, single-peaked):

Why does this matter for probability? The Empirical Rule is an informal preview of the normal distribution (Chapter 5). In Chapter 5, you’ll prove that for a normal random variable XX with mean μ\mu and standard deviation σ\sigma, P(μ2σ<X<μ+2σ)=0.9545P(\mu - 2\sigma < X < \mu + 2\sigma) = 0.9545 — which is where the “95%” comes from. The Empirical Rule is the data-based version of a theoretical probability statement.

6Visualizing Data: Histograms and Relative Frequency

A histogram is a graphical display of the distribution of quantitative data. It groups the data into intervals (called bins or classes) and displays the frequency (or relative frequency) of observations in each interval.

6.1From Data to Histogram

Here’s the key idea: instead of plotting the raw count in each bin, we can plot the relative frequency — the proportion of observations in each bin:

Relative frequency of bin j=count in bin jn\text{Relative frequency of bin } j = \frac{\text{count in bin } j}{n}

When we do this, something remarkable happens: the relative frequencies sum to 1, and the histogram starts to look like a probability distribution.

7From Relative Frequency to Probability

This is the conceptual bridge that connects introductory statistics to probability theory. Pay close attention — this idea underlies the entire book.

When we look at the relative frequency histogram in Example 1.6, we see that 45.0% of the observed inter-arrival times fell in the [0, 1) interval. If we collected more data — say 400 observations, or 4,000, or 40,000 — the relative frequency histogram would get smoother and smoother, and the relative frequencies would settle down to stable values.

Those stable values are probabilities.

And here’s where the magic happens: as nn \to \infty, the relative frequency histogram doesn’t just get smoother — it approaches a smooth curve. That smooth curve is the probability density function (PDF), which is the central object of Chapter 5.

This is the journey of this entire book in miniature: we start with data (histograms), discover patterns (relative frequencies), and build mathematical models (probability distributions) that capture those patterns exactly.

Let’s see this in action. The R function rexp(n, rate) generates nn random values from an exponential distribution (you’ll derive this distribution formally in Chapter 5 — for now, just think of it as a model for waiting times):

# Simulate 100, 1000, and 10000 exponential random variables
par(mfrow = c(1, 3))

for (n_obs in c(100, 1000, 10000)) {
  sim_data <- rexp(n_obs, rate = 1)
  hist(sim_data, breaks = 30, freq = FALSE,
       main = paste("n =", n_obs),
       xlab = "x", ylab = "Density",
       col = "steelblue", border = "white")
  curve(dexp(x, rate = 1), add = TRUE, col = "red", lwd = 2)
}

Run this code. Watch what happens as nn increases: the histogram converges to the red curve. The red curve is the exponential PDF f(x)=exf(x) = e^{-x} for x0x \geq 0. You’ll derive this function from scratch in Chapter 5.

8This Book vs. Intro Stats

If you’ve taken an introductory statistics course (the one with confidence intervals, hypothesis tests, and p-values), you might be wondering: how is this different?

Here’s the honest answer:

Introductory StatisticsProbability Theory (This Book)
FocusUsing formulas to analyze dataDeriving and proving where those formulas come from
Main activityPlug numbers into formulas, interpret outputProve theorems, derive distributions, do calculus
Math levelAlgebraCalculus (integrals, series, multivariable)
The question“What does the data tell us?”“Why does the math behind the data work?”
Random variablesUsed as black boxesDefined, constructed, and analyzed from scratch
DistributionsLooked up in tablesDerived from first principles
Expected valueComputed with a calculatorProved to exist and derived as an integral/sum

In short: Intro stats teaches you to drive the car. This course teaches you to build the engine.

If you haven’t taken intro stats, that’s fine. Chapter 1 (this chapter) and Chapter 2 will give you everything you need. You might actually have an advantage — you won’t have to unlearn the cookbook approach.

9The Road Ahead

Here is what each chapter of this book covers, explained in plain language:

Chapter 2: Probability Foundations. We define the mathematical framework for measuring uncertainty. You’ll learn about sample spaces, events, the axioms that all probabilities must obey, and the counting tools (permutations and combinations) that make complex probability calculations possible. By the end, you’ll solve the Birthday Problem.

Chapter 3: Conditional Probability and Bayes’ Rule. We ask: how does new information change what we believe? You’ll learn to update probabilities when you receive evidence, understand why P(A given B) is not the same as P(B given A), and apply Bayes’ Rule — arguably the most important formula in all of statistics. By the end, you’ll understand why the medical test in Section 1.2 fools everyone.

Chapter 4: Discrete Random Variables. We introduce the concept of a random variable — a function that assigns numbers to random outcomes — and study discrete versions (those that take countable values). You’ll derive and apply the Binomial, Geometric, Negative Binomial, Hypergeometric, and Poisson distributions. You’ll also learn about expected value, variance, and moment generating functions. By the end, you’ll compute the exact probability of any number of heads in any number of coin flips.

Chapter 5: Continuous Random Variables. We extend everything from Chapter 4 to continuous random variables — those that can take any value in an interval. You’ll learn about probability density functions and study the Uniform, Normal, Gamma, Exponential, Chi-Square, and Beta distributions. By the end, you’ll understand why the bell curve appears everywhere in nature.

Chapter 6: Multivariate Distributions. Real life rarely involves just one random variable. We study the joint behavior of two or more random variables simultaneously: joint distributions, marginal distributions, conditional distributions, independence, covariance, and correlation. By the end, you’ll understand Simpson’s Paradox — when combining data reverses the conclusion.

Chapter 7: Functions of Random Variables. The grand finale. If XX has a known distribution and we define Y=g(X)Y = g(X), what is the distribution of YY? We develop three powerful methods — the CDF method, the transformation method, and the MGF method — plus order statistics. By the end, you’ll have the tools to derive any sampling distribution you need in mathematical statistics.

And after this book? The sequel — Mathematical Statistics from the Ground Up — picks up where we left off, covering sampling distributions, estimation, hypothesis testing, and regression. The probability theory in this book is the engine that powers all of it.

9.1The Calculus You’ll Need

This book assumes Calculus I and II. You don’t need to be an expert — but you need to be functional with specific tools. Here’s exactly what you’ll need, chapter by chapter, so you can refresh before it comes up:




10Chapter 1 Refresh Homework

These problems integrate material from all sections of Chapter 1. Unlike the section homework (which targets one topic), refresh problems require you to combine multiple concepts — identifying variables, computing summaries, building histograms, and connecting everything to probability.


R1.1. A city public health department randomly selects 500 restaurant inspections from the past year and records the number of health code violations at each restaurant. The department wants to estimate the average number of violations per restaurant citywide.

(a) Identify all six IVPPSS components. (b) Is the variable discrete or continuous? What type of probability distribution might model this variable? (Think about what you saw in Section 1.2.) (c) If the sample mean is yˉ=3.2\bar{y} = 3.2 violations and s=1.8s = 1.8, interpret both values in context.

R1.2. Consider the Monty Hall Problem described at the beginning of this chapter.

(a) There are three possible scenarios when you initially pick Door 1. List them and their probabilities. (b) In each scenario, explain what Monty does and what happens if you switch. (c) Show that switching wins the car 2/3 of the time. (d) Write R code to simulate the Monty Hall Problem 10,000 times and estimate the probability of winning by switching. Compute the relative frequency of winning by switching and compare it to 2/3. Does the Law of Large Numbers apply here?

R1.3. Two ride-sharing companies in the same city both claim “average pickup time under 8 minutes.” Company A’s pickup times (minutes) for 6 rides: 7.5, 8.2, 7.8, 8.0, 7.6, 7.9. Company B’s pickup times: 3.1, 14.2, 5.8, 11.4, 4.0, 8.5.

(a) Identify the individual, variable, and variable type. (b) Compute yˉ\bar{y} and ss for each company. (c) Both means are close to 8 minutes. Explain, using the standard deviation, why a customer would strongly prefer Company A. (d) If you constructed a relative frequency histogram for each company (with many more observations), predict what each histogram would look like. Which would be more “peaked” near the center?

R1.4. A dataset of 6 values has yi=42\sum y_i = 42 and yi2=350\sum y_i^2 = 350.

(a) Compute yˉ\bar{y}, s2s^2 (shortcut formula), and ss. (b) Is yˉ\bar{y} a parameter or a statistic? Explain. (c) If these 6 values came from a population with true mean μ=8\mu = 8, does yˉ\bar{y} equal μ\mu? Should it? Why or why not?

R1.5. In Example 1.6 (coffee shop inter-arrival times), we observed that 45.0% of the 40 inter-arrival times fell in the [0, 1) interval. The theoretical probability for an exponential distribution with rate λ=1\lambda = 1 is P(0X<1)=1e10.6321P(0 \leq X < 1) = 1 - e^{-1} \approx 0.6321.

(a) Why don’t the observed relative frequency (0.450) and the theoretical probability (0.632) match exactly? (b) What would you expect to happen if we observed 40,000 inter-arrival times instead of 40? (c) Does this difference mean our data does not follow an exponential distribution? Explain using the Law of Large Numbers.

R1.6. A student claims: “The standard deviation tells you the average distance of data points from the mean.” Is this exactly correct? If not, explain what the standard deviation actually measures and why the student’s statement is close but technically wrong. (Hint: Think about squaring.)

R1.7. Write R code to:

(a) Generate 1000 random values from a normal distribution with mean 50 and standard deviation 10. (b) Compute the sample mean and sample standard deviation. Are they exactly 50 and 10? Why not? (c) Plot a relative frequency histogram with the theoretical normal curve overlaid. (d) Explain what you observe, connecting histograms (Section 1.6), relative frequency (Section 1.7), the Law of Large Numbers, and the probability density function.

R1.8. This problem ties together every section of Chapter 1.

A public university wants to understand how long students spend on homework per week. They survey 200 students (the sample) to estimate the true average for all students at the university (the population).

(a) Identify all IVPPSS components and classify the variable type. (Section 1.4) (b) The sample mean is 14.3 hours with s=5.2s = 5.2 hours. Interpret both. (Section 1.5) (c) A relative frequency histogram of the data shows a right-skewed shape with most students between 8–18 hours, a peak around 12 hours, and a long tail extending to 35 hours. What does this shape tell us that the mean alone does not? (Section 1.6) (d) If the university surveyed 20,000 students instead of 200, how would the histogram change? What would the relative frequencies converge to? (Section 1.7) (e) An administrator says: “14.3 hours — that’s the true average for our students.” Is this statement correct? What’s the correct way to state the relationship between 14.3 hours and the true average? (Section 1.4, parameter vs. statistic)


11Chapter 1 Quiz

Test your understanding with this self-assessment quiz. You need 80% (12/15) to earn the badge.