menuSampling and the Central Limit Theorem

Chapter 6: Sampling and the Central Limit Theorem

Learning Objectives

  1. Explain sampling variability: why different samples from the same population give different statistics.
  2. Simulate repeated random samples in Excel with RANDARRAY, INDEX, SORTBY, TAKE and a Data Table, and summarize the results.
  3. Describe a sampling distribution and compute the standard error of a mean (σ/√n) and of a proportion.
  4. Explain why quadrupling the sample size halves the standard error.
  5. State the central limit theorem and show it at work on skewed data.
  6. Read and run an R simulation script, and explain why simulation results vary unless a seed is set.

6.1 How Big Should the Next Survey Be?

Ridgeline's customer survey cost real money: 600 customers, each given a free pastry for their time. Dana Whitfield is planning next year's survey and asks a fair question: "Why 600? Would 100 have told us the same thing for a sixth of the cost? Or should we survey more people?"

You know from Chapter 1. Statistics, Data, and AI in Business that the survey is a sample, and that the average spend of $8.48 among the 600 respondents is a statistic, used to estimate the average spend of all customers, an unknown parameter. Dana's question is really this: how close to the truth is a sample statistic likely to be, and how does that depend on the sample size?

You can't answer that by surveying all of Ridgeline's customers. But you can do something almost as good. Treat the 600 survey responses as if they were the entire population, draw many small samples from them, and watch what happens. That's a simulation, and Excel can run one in a few minutes. What you'll see in this chapter is the foundation of everything in the second half of the book: confidence intervals, hypothesis tests and every comparison between groups.

6.2 Sampling Variability

Start with a fact you can check. The first 25 rows of the Survey Table are 25 customers, a perfectly reasonable small sample. Their mean spend is:

The mean of all 600 is 8.48. The first 25 customers happened to spend about a dollar more on average. If you'd stopped the survey after 25 responses, you would have told Dana that customers spend about $9.51 a visit, and you'd have been off by more than 12%.

Nothing went wrong in that sample. It's just how samples behave. Each sample contains different customers, so each gives a different mean. This is called sampling variability.

Sampling variability — The natural variation in a statistic from one random sample to another, because each sample contains different individuals.

Sampling variability isn't a mistake that better data collection can remove. It's built into sampling. What you can do is measure how large it's likely to be. That's what the rest of this chapter is about.

Sampling variability isn't the same as bias. If the survey had included only mobile-app customers, its mean would be off in a particular direction no matter how many people you asked. That's bias, and a bigger sample doesn't fix it. Sampling variability is random scatter around the truth, and it gets smaller as samples get larger.

6.3 A Simulation in Excel

6.3.1 The setup

For the next few sections, pretend the 600 survey spends are the whole population of Ridgeline customers. That's a trick, but a useful one: it means you know the population's true mean and standard deviation, so you can see exactly how far each sample lands from the truth.

Because the 600 values are now a population, describe them with the population formulas from Chapter 4. Describing Data. Population parameters are usually written with Greek letters: μ ("mu") for the mean and σ ("sigma") for the SD.

A simulation uses random numbers to imitate a random process many times so you can see the pattern of results.

Simulation — Using a computer to imitate a random process, such as drawing a random sample, many times over, and then studying the pattern of results.

6.3.2 Drawing one random sample

  1. Add a new worksheet and name it Sim.

  2. In A1 type n, and in B1 type 25. This cell holds the sample size, so you can change it later.

  3. In A3 type sample. In A4 enter:

    =INDEX(Survey[spend],RANDARRAY($B$1,1,1,ROWS(Survey[spend]),TRUE))

    It spills 25 spend values down column A.

Read the formula from the inside out. RANDARRAY($B$1,1,1,600,TRUE) makes a column of 25 random whole numbers between 1 and 600, which are row positions. (ROWS(Survey[spend]) supplies the 600.) INDEX(Survey[spend], …) then picks the spend in each of those rows. Every customer has the same chance of being picked each time, so this is a random sample.

  1. In C3 type sample mean, and in C4 enter =AVERAGE(A4#).

Now press F9. Excel recalculates every formula, RANDARRAY draws new row numbers, and you get a new sample with a new mean. Press F9 ten or twenty times and watch C4. You might see 8.12, then 9.03, then 8.47, then 7.88. Your numbers will be different from these and from your classmates', because each recalculation draws a new random sample. Every number in this section that comes from a simulation will vary a little each time.

The Sim sheet: B1 = 25; A4 shows the INDEX/RANDARRAY formula in the formula bar and spills 25 spend values (A4:A28) with a thin blue spill border; C4 shows the sample mean (for example 8.31). A callout says "Press F9 for a new sample."

With or without replacement. The INDEX/RANDARRAY formula samples with replacement: the same customer can, rarely, be picked twice. To sample without replacement, shuffle the column and keep the first n: =TAKE(SORTBY(Survey[spend],RANDARRAY(ROWS(Survey[spend]))),$B$1). When the sample is small compared with the population, the two give nearly identical results. This chapter uses sampling with replacement because the formulas for the standard error assume it.

6.3.3 Drawing 1,000 samples with a Data Table

Pressing F9 shows sampling variability, but to see its pattern you need hundreds of sample means side by side. A Data Table can recalculate the sheet once per row and record the result each time.

  1. In E3 leave the cell empty. In F3 enter =C4. This is the cell the Data Table will record.
  2. In E4 type 1. Select E4, choose Home > Fill > Series…, pick Columns, set Step value to 1 and Stop value to 1000, and click OK. Column E now numbers the trials 1 to 1,000 (E4:E1003).
  3. Select E3:F1003.
  4. Choose Data > What-If Analysis > Data Table….
  5. Leave Row input cell empty. For Column input cell, click any empty cell that no formula uses, such as H1. Click OK.

Excel fills F4:F1003 with 1,000 sample means. Each row of a Data Table recalculates the whole sheet, so each row gets its own fresh random sample of 25. (The Column input cell only needs to be a cell nothing depends on. You're using the Data Table purely to repeat the calculation.)

The Sim sheet with E3:F1003 selected and the Data > What-If Analysis > Data Table dialog open: Row input cell empty, Column input cell $H$1. Column E shows trial numbers 1, 2, 3, …; F3 contains =C4.

Data Tables can slow a workbook down. Every recalculation redraws all 1,000 samples. If Excel becomes sluggish, choose Formulas > Calculation Options > Automatic Except for Data Tables. The Data Table then updates only when you press F9.

6.3.4 Summarizing the 1,000 sample means

In H3:H6, type the labels mean of means, SD of means, theory σ/√n and skewness. In I3:I6 enter:

Then select F4:F1003 and choose Insert > Insert Statistic Chart > Histogram.

Your results will differ slightly from anyone else's, but they'll look like this. The mean of the 1,000 sample means will be very close to 8.48, the population mean μ. Their SD will be close to 0.52. And the histogram will be a tidy, symmetric hump centered on 8.48, with most sample means between about $7.50 and $9.50.

A histogram of the 1,000 simulated sample means (n = 25) from F4:F1003: a symmetric bell shape centered near 8.5, running from roughly 7 to 10. Beside it, the summary cells: mean of means ≈ 8.48, SD of means ≈ 0.52, theory σ/√n = 0.516, skewness near 0.

6.4 The Sampling Distribution and the Standard Error

What you've just built is a picture of a sampling distribution: the distribution of a statistic (here, the sample mean) over all the random samples you could draw.

Sampling distribution — The distribution of a statistic, such as a sample mean, across all possible random samples of the same size from the same population. It shows which values the statistic is likely to take.

Be careful to keep three distributions apart:

Distribution What's in it For spend
The population every customer's spend 600 values, mean 8.48, SD 2.58
One sample the n customers you happened to draw 25 values, mean somewhere near 8.48
The sampling distribution the means of many samples of size n 1,000 means, centered at 8.48, SD about 0.52

The sampling distribution has three features that matter:

  1. Its center is the population mean. Sample means don't systematically run high or low. On average they hit μ. (Statisticians say the sample mean is unbiased.)
  2. It's much narrower than the population. Individual customers' spends vary with an SD of $2.58. Means of 25 customers vary with an SD of only about $0.52. Averaging cancels out much of the individual variation: a high spender and a low spender in the same sample pull the mean in opposite directions.
  3. Its shape is close to normal, even though nobody told the data to be normal. More on that shortly.

The standard deviation of a sampling distribution has its own name: the standard error.

Standard error (SE) — The standard deviation of a statistic's sampling distribution. It measures how far the statistic typically falls from the population value. For a sample mean, SE = σ / √n.

The standard error of the mean has a simple formula. In words: divide the population SD by the square root of the sample size. In symbols:

SE = σ / √n

In Excel: =STDEV.P(Survey[spend])/SQRT(25) returns 2.582 / 5 = 0.516. That's the number your simulated SD of means was close to. The formula predicts what the simulation shows, without drawing a single sample.

The SE has the same units as the data, so you can read it directly: a sample mean of 25 customers' spending is typically about 52 cents away from the true mean. That's the sentence Dana needs. A spread that size means a sample of 25 can easily land a dollar away from the truth, as the first 25 rows did.

Standard deviation or standard error? The SD describes how much individual values vary. The SE describes how much a statistic (like a mean) varies from sample to sample. The ToolPak's Descriptive Statistics output from Chapter 4. Describing Data reports both. Its "Standard Error" is the sample SD divided by √n.

In real work you never know σ, because you don't have the whole population. You use the sample's SD in its place, so the SE becomes s / √n. With the full survey, that's =STDEV.S(Survey[spend])/SQRT(600) = 0.106. Chapter 7. Confidence Intervals uses exactly this number.

6.5 Larger Samples, Smaller Standard Errors

Now answer Dana's question about sample size. Change B1 to 5, press F9, and record the SD of means. Then try 10, then 100. (If you set calculation to "Automatic Except for Data Tables," press F9 after each change.) Compare what you see with the formula:

Sample size n √n SE = 2.582 / √n Typical miss
5 2.24 1.155 about $1.16
10 3.16 0.816 about $0.82
25 5 0.516 about $0.52
100 10 0.258 about $0.26

Your simulated SDs will land near these values, a little above or below each time.

Look at how the SE shrinks. Going from 25 to 100 customers, four times as many, cuts the SE from 0.516 to 0.258, exactly in half. That's the square root at work: √4 = 2. To halve the standard error, you need four times the sample size. To cut it to a third, you need nine times the sample.

That has a direct business meaning. Precision gets expensive. The first 100 customers buy you a lot: the SE drops from $1.16 at n = 5 to $0.26 at n = 100. Each further improvement costs more. Going from 600 to 2,400 customers would cost four times as much and only halve the SE again, from about $0.11 to about $0.05.

For Dana, the answer is that 100 customers would estimate average spend to within about a quarter of a dollar, typically, which is fine for many purposes. The 600-customer survey is about 2.4 times more precise (√6 ≈ 2.45), and it's large enough to also compare the three regions, each of which has about 200 responses. Whether that extra precision is worth the extra pastries depends on the decisions it supports. Chapter 7. Confidence Intervals shows how to choose a sample size for a precision you name in advance.

The population size barely matters. The formula σ/√n doesn't include the population size at all. A random sample of 400 customers gives about the same precision whether Ridgeline has 10,000 customers or a million. What matters is the size of the sample, not the share of the population it covers. (When the sample is a large share of the population, the SE is a little smaller than σ/√n, but that rarely applies in business surveys.)

6.6 The Central Limit Theorem

Survey spend is roughly symmetric to begin with (skewness −0.03), so it isn't surprising that its sample means look normal. The more striking fact is that sample means look normal even when the data don't.

Take visits_per_week, which you know is strongly right-skewed: most customers visit 1–3 times a week, a few visit far more, and the skewness is 1.12. As a population, its mean is μ = 2.830 and its SD is σ = 2.101.

You can rerun your Excel simulation on it. On the Sim sheet, change Survey[spend] to Survey[visits_per_week] in the A4 formula and in the theory formula in I5, then set B1 to 5 and then 30. The book's own simulation, with 10,000 samples of each size, gave these results:

Customers (population) Means of n = 5 Means of n = 30
Mean 2.830 2.818 2.829
SD (of the values or of the means) 2.101 0.944 0.382
Theory: σ/√n 0.940 0.384
Skewness 1.119 0.477 0.193

Three things happen as n grows:

This is the central limit theorem, one of the most important results in statistics.

Central limit theorem (CLT) — For random samples of size n from almost any population with mean μ and standard deviation σ, the sampling distribution of the sample mean is approximately normal with mean μ and standard deviation σ/√n, and the approximation improves as n grows.

Why does it happen? A sample mean adds up many values. Some customers in a sample visit a lot and some visit a little. Extreme values are rare, and in a sample of 30 they're mixed in with many ordinary ones, so their effect is diluted. The more values you average, the more the random highs and lows cancel, and the result is the symmetric bell shape that the normal distribution describes. The underlying data can be skewed, lumpy, or limited to a few whole numbers, as visits per week is.

How large must n be? There's no single answer. For roughly symmetric data like spend, samples as small as 10 or 15 give nearly normal means. For moderately skewed data like visits per week, means of 30 are close to normal. For extremely skewed data, such as the dollar value of catering orders where a few orders are huge, you may need well over 100. "n ≥ 30" is a common rule of thumb, but look at the data's shape too.

Three histograms side by side, from the R script later in this chapter: (1) visits_per_week for the 600 customers, strongly right-skewed with a peak at 1–2 and a tail to 14; (2) means of samples of 5, still somewhat right-skewed, centered near 2.8; (3) means of samples of 30, nearly symmetric and bell-shaped, centered near 2.8 and much narrower.

The CLT is about means, not individual values. It doesn't make the data normal. Individual customers' visits stay just as skewed however many you survey. In Chapter 5. Probability and Distributions a normal model for one customer's visits gave impossible answers, and it still does. What becomes normal is the average of many customers.

That's why the CLT matters so much. In Chapter 5. Probability and Distributions you could only use normal-model probabilities when the data themselves were close to normal. Thanks to the CLT, you can use normal-model reasoning about sample means for almost any data, as long as the sample is reasonably large. Every method in the next several chapters relies on it.

6.7 The Standard Error of a Proportion

Many business questions are about a percentage, not an average: the share of customers who would recommend Ridgeline, the share who redeem a coupon. A sample proportion is also a statistic, so it has a sampling distribution and a standard error too.

In the full survey, the proportion who would recommend is p = 407/600 = 0.678. Treat that as the population value and imagine surveying n customers. In words: the SE of a proportion is the square root of p times (1 − p), divided by n. In symbols:

SE = √[ p(1 − p) / n ]

In Excel: =SQRT(0.678*(1-0.678)/50) returns 0.066.

Sample size n SE of the proportion In percentage points
50 0.066 about 6.6
200 0.033 about 3.3
600 0.019 about 1.9

The same square-root rule applies: 200 is four times 50, and the SE halves from 0.066 to 0.033. A survey of 50 customers would typically miss the true recommend rate by more than 6 percentage points, enough to make a 68% chain look like a 61% or a 74% chain. With 600 customers, the typical miss is under 2 points.

You can simulate this too. A Yes/No column becomes a proportion if you count the "Yes" answers in each sample:

The ="Yes" comparison gives TRUE or FALSE for each customer drawn, and the -- turns those into 1s and 0s, so their average is the proportion of Yes answers. Put this in C4 in place of the spend mean, set B1 to 50, and your Data Table produces 1,000 sample proportions. Their SD will be close to 0.066. By the CLT, the sample proportion is also approximately normal when n is large enough. A common check is that you'd expect at least 10 Yes and 10 No answers in a sample: n × p ≥ 10 and n × (1 − p) ≥ 10.

6.8 Simulating With R for Excel

Excel's Data Table is good for 1,000 samples. For 10,000 samples of several sizes, R is faster and simpler. It's also a chance to see one thing that's easy to miss in an AI-written simulation: whether the results can be reproduced.

Set up R for Excel:

  1. In 1. Data, click Add a table… and choose Survey.
  2. In 2. Ask your AI, type the data description below.
  3. Click Copy prompt, and paste it into your AI assistant.
Each row of Survey is one Ridgeline Coffee customer's survey response (600 rows). visits_per_week is how many times a week the customer usually visits (a whole number from 0 to 14); it is strongly right-skewed.
Question: How does the sampling distribution of the mean of visits_per_week change between samples of 5 and samples of 30? I want to see the central limit theorem at work.
I'm in an intro business statistics course and have learned sampling distributions, the standard error (sigma divided by the square root of n) and the central limit theorem.
Please treat the 600 values as the population. Use set.seed so the results can be reproduced. Draw 10,000 random samples (with replacement) of size 5 and of size 30, and for each size report the mean of the sample means, their standard deviation, the theoretical standard error and the skewness of the means. Send that table to Excel with excel_out(), draw histograms of the data and of both sets of means, and explain how to read the results.

Needs: a reply with a base-R script that calls set.seed, uses replicate() with mean(sample(Survey$visits_per_week, n, replace = TRUE)) for n = 5 and n = 30, computes the population SD with the divide-by-n formula (or notes the difference from sd()), computes skewness in base R without a package, sends a two-row summary table with excel_out(), and draws three histograms. The explanation should point out that the SD of the means is close to sigma/sqrt(n) and that the skewness shrinks as n grows. The text after this block compares the script with the walkthrough below.

6.9 Read the Script

A script for this usually looks like the one below.

set.seed(2025)   # fixes the random draws so the results can be repeated

visits <- Survey$visits_per_week
sigma <- sqrt(mean((visits - mean(visits))^2))   # population SD, like STDEV.P

# 10,000 random samples of each size; keep each sample's mean
means_5  <- replicate(10000, mean(sample(visits, 5,  replace = TRUE)))
means_30 <- replicate(10000, mean(sample(visits, 30, replace = TRUE)))

# Skewness of a set of numbers (close to Excel's SKEW for large sets)
skew <- function(v) mean((v - mean(v))^3) / sd(v)^3

results <- data.frame(
  sample_size   = c(5, 30),
  mean_of_means = round(c(mean(means_5), mean(means_30)), 3),
  sd_of_means   = round(c(sd(means_5), sd(means_30)), 3),
  theory_se     = round(sigma / sqrt(c(5, 30)), 3),
  skewness      = round(c(skew(means_5), skew(means_30)), 3))
excel_out(results, "Simulated sample means of visits per week")

# Histograms: the customers, then the two sets of sample means
par(mfrow = c(1, 3))
hist(visits, main = "Customers", xlab = "Visits per week")
hist(means_5, main = "Means of 5", xlab = "Mean visits", xlim = c(0, 8))
hist(means_30, main = "Means of 30", xlab = "Mean visits", xlim = c(0, 8))

Walk through it in plain language:

Check the AI's version for the same pieces. In particular, does it sample with replacement? Does it compute σ with n (not n − 1)? With 600 values the difference is tiny, but it should be what you asked for. And does it set a seed?

6.10 Run It and Interpret

  1. Paste the AI's reply into 3. Run R code and click Run. Ten thousand samples take a few seconds.
  2. Under Results, send the output card "Simulated sample means of visits per week" to a New sheet.
  3. Click Insert into Excel under the histograms to place them beside the table.

The R for Excel Results area after running the simulation: three side-by-side histograms (Customers, Means of 5, Means of 30) with an Insert into Excel button, and the output card "Simulated sample means of visits per week" previewing two rows with sample_size, mean_of_means, sd_of_means, theory_se and skewness.

Your table won't match the book's numbers exactly, because the book's simulation used different random draws. It should be close: means of means near 2.83, SDs of means near 0.94 and 0.38, theoretical SEs of 0.940 and 0.384, and skewness that drops from about 0.5 at n = 5 to about 0.2 at n = 30. Run the script twice with the same seed, and you'll get identical numbers. Delete the set.seed line and run it twice, and the numbers will change slightly each time.

Verify. The theoretical SE doesn't depend on any random draws, so check it exactly in Excel: =STDEV.P(Survey[visits_per_week])/SQRT(30) returns 0.384. Then compare it with your own Excel simulation of visits from earlier. Both tools should agree that means of 30 customers vary by about 0.38 visits.

What to tell Dana.

A survey's average is never exact, but its typical error is predictable: it's the spread of individual customers divided by the square root of the sample size. For average spend, a survey of 100 customers is typically within about 26 cents of the true average, and our 600-customer survey within about 11 cents. Each halving of that error costs four times as many responses, so a much larger survey isn't worth it for average spend. Keep the survey near its current size, which still leaves about 200 responses per region for comparing the regions.

6.11 Why This Matters for the Rest of the Book

Look back at what you can now say. Before this chapter, a sample mean was just a number. Now you know three more things about it:

  1. It's centered on the population mean it estimates.
  2. It typically misses by about one standard error, σ/√n.
  3. Its sampling distribution is close to normal when the sample is reasonably large, whatever the shape of the data.

Put those together with the normal distribution from Chapter 5. Probability and Distributions and you get powerful statements. By the empirical rule, about 95% of sample means fall within about 2 standard errors of the population mean. Turn that around: if you go about 2 SEs either side of your sample mean, the range you get will contain the population mean for about 95% of samples. That's a confidence interval, the subject of Chapter 7. Confidence Intervals.

And if someone claims the population mean is a particular value, you can ask how many standard errors your sample mean is from it. If it's far, say 4 or 5 SEs, the claim is hard to believe. That's a hypothesis test, the subject of Chapter 8. Hypothesis Testing. Every test in the second half of the book, from comparing promo days with ordinary days to testing a regression slope, is a version of that question.

6.12 Summary

Different random samples from the same population give different statistics. That's sampling variability, and it's unavoidable. The first 25 survey responses, for example, had a mean spend of $9.51, compared with $8.48 for all 600. By treating the 600 survey responses as a population and drawing many random samples with INDEX and RANDARRAY (repeated with a Data Table), you built a sampling distribution: the distribution of a statistic across many samples. It's centered on the population value, and its standard deviation, the standard error, equals σ/√n for a mean (0.516 for samples of 25 spends) and √[p(1 − p)/n] for a proportion. Because of the square root, quadrupling the sample size halves the standard error, so precision gets expensive as samples grow.

The central limit theorem says that sample means are approximately normal for large enough samples, even when the data are skewed. Means of 30 values of the skewed visits-per-week variable had skewness of only about 0.19 and an SD of 0.38, matching the theoretical 0.384. Simulation results vary from run to run, in Excel each time it recalculates and in R unless you set a seed, so your numbers will differ slightly from the book's. The ideas you built here, the standard error and the near-normal sampling distribution, are the foundation for confidence intervals and hypothesis tests in the chapters ahead.