Unit 2

Probability, Statistics, Hypothesis Testing and Experiment Design

Probability, Sampling, Hypothesis Testing and Experiment Design · Data, Models, and AI-Empowered Decision Making
2.1 Foundations of Probability and Statistics 2.2 The Four-Step Hypothesis-Testing Procedure 2.3 AI-Assisted Experiment Design 2.4 A/B Test Case 2.5 Summary and Assignment 5 interactive demonstrations · 5 classroom exercises
How to use this e-textbook. Orange panels are interactive demonstrations where you can move sliders, change parameters and resample; charts and figures recalculate immediately. Green panels are classroom exercises; complete them and select “Check” for feedback and reference values. This page uses real course data:11,121 order values,heights of 771 male and 667 female athletes,400-row and 4,000-row social-media A/B-test data sets. All answers and reading progress are stored in this browser and survive a refresh.

2.1 Foundations of Probability and Statistics

This section establishes three foundations: how to describe randomness, why a sample can represent a population, and why the sample mean can be approximated by a normal distribution. These ideas underpin every hypothesis test that follows.

Random Variables and Probability Distributions

  • Random variable a quantity whose value depends on chance, such as the number of orders in a day or the amount one customer spends.
  • Discrete values are countable points, such as the number of items in an order, the number of defect-free products or the number of clicks.
  • Continuous values lie on an interval, such as money, duration or temperature.
Discrete: each value has its own probability Items per order (countable) Continuous: described by a density curve Amount / duration (values on an interval)
First determine which type of variable matters, then choose the distribution used to describe it—that choice is the starting point of every statistical analysis.

A probability distribution is a probability map of possible values; it answers how common each outcome is. Before analysing data, ask: which type of quantity am I studying?

The Normal Distribution: Shape and Parameters

Many management measures are common near the centre and rare in the tails, so the normal distribution is the most common approximation.The mean positions the curve horizontally; the standard deviation controls how narrow or wide it is. The demonstration below lets you drag both parameters and see the shape change directly.

Interactive Demonstration 1

Normal-Distribution Workbench: Mean and Standard Deviation

Drag the sliders to change μ and σ and observe how the curve shifts and widens. Enter a value to see its left-tail probability (Excel NORM.DIST) and standard score (STANDARDIZE).

Value x to evaluate:
Standard score z
Left-tail probability P(X ≤ x)
Right-tail probability
Share within 1σ
Share within 2σ
Share within 3σ

Standardisation, the Empirical Rule and Excel Functions

Key ideaMeaningExcel function
StandardisationConvert a value into the number of standard deviations it lies from the mean=STANDARDIZE(x, mean, standard_deviation)
Left-tail probabilityShare of observations below a specified value=NORM.DIST(x, mean, standard_deviation, TRUE)
Inverse calculationFind the value associated with a specified probability=NORM.INV(probability, mean, standard_deviation)
Empirical ruleAbout 68% lie within one standard deviation, about 95% within two and about 99.7% within three—
The empirical rule applies only when the data are approximately normal. Order values in the previous unit are right-skewed, so 77%—not 68%—lie within one standard deviation. For clearly skewed data, inspect the median and box plot before deciding whether a normal approximation is appropriate.

Populations, Samples and Random Sampling

  • Population the complete set of objects of interest, such as the distribution of all order values.
  • Sample the subset of data actually available, such as the 11,121 orders observed this month.
  • Random sampling every object has the same probability of selection. Once sampling becomes “choosing the data,” every subsequent conclusion is invalid.
  • Larger samples bring sample statistics closer to population parameters, but no increase in sample size can repair a biased sampling method.

Sampling Distributions and the Central Limit Theorem

If we repeatedly sample from the same population and calculate a sample mean each time, those means form a distribution called the sampling distribution of the sample mean. Its mean equals the population mean, and its standard deviation is called the standard error, equal to the population standard deviation divided by the square root of the sample size:

Standard error SE = σ / √n Quadrupling the sample size only halves the standard error

Central limit theorem for a sufficiently large sample, the distribution of the sample mean is approximately normal, regardless of the distribution of the underlying data. Even when the raw data are right-skewed, the sample mean can be approximated by a normal distribution; in practice, n around 30 is often sufficient. This is why confidence intervals and hypothesis tests work.

Interactive Demonstration 2

Verify the Central Limit Theorem with 11,121 Real Orders

Each round draws n orders at random and calculates their mean; repeating the process produces the sampling distribution of the sample mean. Change n and watch the histogram move from right-skewed toward bell-shaped.

Observations per draw (n):
Number of repetitions:
Mean of sample means
Standard deviation of sample means
Theoretical standard error σ/√n
Population mean

Confidence Intervals and Margin of Error

A point estimate gives one number; a confidence interval gives a range. Its width depends on the confidence level, standard deviation and sample size:margin of error = critical value × standard error. When the population standard deviation is unknown, substitute the sample standard deviation and replace the normal critical value with a t critical value.

Sample mean ± tα/2 × s / √n For example, 102.84 ± 1.07 (95% confidence interval)
Interactive Demonstration 3

Confidence-Interval Workbench: Repeated Sampling and Coverage

Draw repeated samples from the real orders and compute one interval per sample. Blue intervals cover the population mean of 102.84; red intervals do not. Change the confidence level and sample size to see how coverage and interval width respond.

Confidence level:
Sample size n:
Sample mean for this draw
Margin of error
Interval for this draw
Share of 100 intervals that cover the true value

Confidence Intervals in Excel

SituationExcel functionMethod
Population standard deviation known=CONFIDENCE.NORM(α, σ, n)Use the normal critical value
Population standard deviation unknown=CONFIDENCE.T(α, s, n)Use the t critical value; this is the more common case
Interval notationsample mean ± margin of errorFor example, 102.84 ± 1.07

A confidence interval means that if we repeated sampling many times, about 95% of intervals would cover the true population mean. It does not mean “there is a 95% probability that the parameter lies in this particular interval”—the parameter is fixed; only the interval is random.

The Duality of Confidence Intervals and Hypothesis Tests

  • If a 95% confidence interval excludes a value, a two-tailed test at that value would be rejected.
  • The two tools are different statements of the same result; reporting the interval is more informative than reporting only a p-value.
  • The interval also answers how large the effect might be and how uncertain it is—the information managers need.

2.2 The Four-Step Hypothesis-Testing Procedure

This section does one thing: turn “is this difference real?” into a repeatable process. Once you master the four steps, proportion tests, mean-difference tests and A/B tests all follow the same pattern.

Core Logic: Three Samples

A newly calibrated filling machine should place 200 mL in each bottle. Three samples produce three different sample means:

Sample meanIntuitive judgementReason
170 mLThe machine is not calibratedToo far from 200 to be ordinary random variation
200.0 mLThe machine is operating correctlyExactly at the target
199.1 mLCannot tell; a test is neededThe difference is small, but cannot be judged by intuition alone

The third case is what statistics is designed to resolve. The judgement must account for:sample size,the variability of the sample, and the significance level we are willing to accept.

Null and Alternative Hypotheses

Null hypothesis H₀

the proposition assumed true initially, usually “no change” or “no difference.”
Filling example: H₀: μ = 200

Alternative hypothesis HA

the proposition we hope the data will support.
Filling example: HA: μ ≠ 200

A test can reach only two conclusions:reject H₀ or fail to reject H₀. “Fail to reject” does not mean “H₀ has been proved”; it means the evidence is insufficient.

Rejection Regions and Significance Levels

Acceptance region (do not reject H₀) Rejection region Rejection region α/2 = 0.025 α/2 = 0.025 −2.262 +2.262 Sampling distribution (t with 9 degrees of freedom; two-tailed α = 0.05)
A two-tailed test divides α equally across the two tails; if the statistic falls in a rejection region, reject the null hypothesis.

The significance level α is the probability we accept of incorrectly rejecting H₀; 0.05 and 0.01 are common. If the sample statistic falls in the rejection region, reject the null hypothesis.

z and t Test Statistics

The test statistic measures how many standard errors separate the sample from the hypothesised value. Use z when the population standard deviation is known; use t with the sample standard deviation when it is unknown. The t distribution is heavier-tailed because it includes the uncertainty of estimating the standard deviation; degrees of freedom = n − 1.

z = (x̄ − μ₀) / (σ/√n) t = (x̄ − μ₀) / (s/√n)

As the sample grows, the t distribution approaches the normal distribution. Beyond n = 100, the critical values differ only slightly.

The Four-Step Hypothesis-Testing Procedure

  1. Formulate the hypotheses state the null H₀ and alternative HA; the null must contain an equality.
  2. Calculate the test statistic choose the correct formula: use t when the population standard deviation is unknown and z for proportions.
  3. Determine the critical value use the significance level and degrees of freedom to obtain the rejection region.
  4. Reach a conclusion if the statistic lies in the rejection region, reject H₀ and state the implication in business language: “therefore, we should do this.”
Classroom Exercise 1

Complete the Four Steps for the Filling Example

The target is 200 mL. Ten bottles produce a sample mean of 199.1 mL and a sample standard deviation of 1.2 mL; α = 0.05. Choose an answer at each step and select Check.

One-Tailed Tests and Rules for Formulating the Null

Use a one-tailed test when only one direction matters; the rejection region lies at one end. A one-tailed critical value is smaller and makes rejection easier, so the direction must be specified before seeing the data; otherwise, you are effectively choosing the conclusion.

Cannot serve as the null hypothesisCan serve as the null hypothesisReason
≠=The null must contain an equality so that the rejection region has a clear boundary
>≥
<≤

Example: a manufacturer claims that mean male height exceeds 173 cm; write the null as μ ≤ 173 and the alternative as μ > 173.

Proportion Test: A Golf Course Example

Historically, 20% of customers were women. After a promotional campaign, a random sample of 400 customers contains 100 women, for a sample proportion of 25%. Is the five-percentage-point increase real or sampling variation?

ItemCalculationResult
HypothesesH₀: p ≤ 0.20, HA: p > 0.20One-tailed test
standard error√(0.20 × 0.80 ÷ 400)0.02
z statistic(0.25 − 0.20) ÷ 0.022.50
p-value=1−NORM.S.DIST(2.50,TRUE)0.0062
Conclusionp < 0.05Reject H₀; the campaign is effective

Business interpretation: there is sufficient evidence that the proportion of female customers exceeds 20%, so the campaign merits continuation.

Classroom Exercise 2

Complete This Proportion Test Yourself

Using the data above, complete four fields: standard error, z statistic and one-tailed p-value, then choose the conclusion. Being in the correct order of magnitude counts as correct.

Difference in Two Means and Paired Tests

Whether two group means differ is one of the most common practical questions: average order value under old versus new approaches, dwell time for two user groups, or heights of male and female athletes. Before testing, ask:Are the two groups independent, or are these two observations of the same objects?

SituationAppropriate methodKey idea
Independent groups with similar spreadTwo-sample t-test with equal variancesDegrees of freedom = n₁ + n₂ − 2
Independent groups with clearly different spreadWelch two-sample t-test with unequal variancesDegrees of freedom require an adjustment; Excel calculates it automatically
Same objects observed before and afterPaired t-testTests the mean of the differences; observations must be matched one to one
Treating paired data as two independent samples can reverse the conclusion. Pre/post training scores, left and right hands of the same person, and two months of sales at the same store are paired data.
Interactive Demonstration 4

Test a Difference in Means Using Real Height Data

The data are the real classroom athlete data (771 men and 667 women). This demonstration uses a Welch t-test and also shows box plots so you can compare the mean difference with the spread.

Difference in means
t statistic
Degrees of freedom
Two-tailed p-value

Type I and Type II Errors and Statistical Power

H₀ is actually true H₀ is actually false Conclusion: do not reject H₀ Conclusion: reject H₀ Correct: do not reject Conclusion agrees with reality; probability 1 − α Type I error α H₀ is true but rejected; its probability is set in advance Type II error β H₀ is false but the test fails to detect it Correct: reject Power = 1 − β
α is chosen in advance; β falls with a larger sample. Power = 1 − β is the probability of detecting a difference when one truly exists.

“Not significant” has two possible explanations: no real difference, or too small a sample. This is why an A/B test must begin with a sample-size calculation—if the sample is too small, even a completed experiment cannot support a conclusion.

Hypothesis-Testing Summary

  • Four steps: formulate hypotheses, calculate the statistic, determine the critical value and reach a conclusion.
  • Use t tests for means, z tests for proportions, and determine whether groups are paired before comparing them.
  • Reject the null only when p < α; a p-value is not “the probability that the conclusion is correct.”
  • Significance is not the same as importance; examine effect size and business meaning, and report the effect, confidence interval and sample size together.
Classroom Exercise 3

Which Test Fits Each Situation?

The following five statements describe real business questions. Choose the most appropriate test for each.

2.3 AI-Assisted Testing and Experiment Design

AI plays two roles in this section: helping you write a complete experiment plan, and providing a “professional-looking” interpretation once results exist. The latter must be verified item by item.

Designing an Experiment with AI: One Prompt, Five Questions

AI step

Prompt template
I want to test whether [change] improves [metric], in the context of [setting and constraints].
Please provide: 1) the null and alternative hypotheses; 2) the appropriate test and rationale; 3) an approach for estimating sample size; 4) the assumptions to check; and 5) the three most common mistakes when drawing conclusions.

QuestionRequirementCommon error
How is the metric defined?Provide the numerator, denominator and measurement windowSaying only “click-through rate” without defining the metric
How large a sample is needed?Provide the calculation basis and minimum sample sizeClaiming that “a few hundred observations should be enough”
How are users assigned?Use random assignment and state the allocation ratioAssigning by time sequence, which introduces temporal bias
How long should the experiment run?Cover a complete business cycleRunning for only two days and ignoring weekday/weekend effects
When should the experiment stop?Agree on a stopping rule in advanceStopping when the result becomes significant, which inflates false positives

Ask AI to Interpret Test Results, Then Verify Every Claim

Paste the Excel t statistic, p-value and the two group means into AI. Ask for a business-language interpretation and an actionable recommendation; then ask what assumptions the conclusion relies on and have AI list its three most likely errors. Finally,verify every item in Excel.

Your verification actionCommon AI error
Recalculate the test statistic and p-value with Excel Analysis ToolPakChoosing the wrong test type, such as two-sample instead of paired
Check whether the two sample sizes and allocation ratio are balancedIgnoring sample size and interpreting non-significance as no difference
Confirm one-tailed versus two-tailedMixing one- and two-tailed tests, or choosing the direction after seeing the data
Judge whether the effect size is large enough to justify actionCalling statistical significance a large business improvement
Check assumptions and experiment durationIgnoring variance assumptions or the novelty effect
Classroom Exercise 4

Find the Problems in This AI-Generated Experiment Plan

Below is an A/B experiment plan generated by AI (a teaching example). Select a sentence to mark it as “problematic,” then select Check. The plan contains four problems.

Verification framework: metric definition, sample-size rationale, assignment method, experiment duration and stopping rule—one problem for each.

2.4 A/B Test Case: Comparing Headlines for Social-Media Content

This is the unit’s integrated case. A knowledge-focused social-media account wants more people to open the same piece of content: the platform randomly shows two versions to two groups, with Group A receiving the original headline and Group B the new headline. Every number below is calculated in real time from real data embedded in the page.

Why Run A/B Tests? First Understand Core Web Metrics

Websites and apps record everything: who saw what and when, what they clicked, how long they stayed and whether they returned the next day. These records are summarised into several common metrics.

MetricHow it is calculatedQuestion it answers
ImpressionNumber of times a page or piece of content is displayedHow many people saw it?
Click-through rate (CTR)clicks ÷ impressionsOf those who saw it, how many were interested?
Conversion rate (CVR)Users completing the target action ÷ users reaching that stageOf those who were interested, how many acted?
Retention rateUsers returning on day or week N ÷ first-time usersDid users stay?

Arranging these stages in sequence produces a funnel model: users enter through impressions and proceed stage by stage, with some loss at every layer. The funnel’s value is that it breaks “poor performance” into “which layer underperforms”.

100,000 impressions 24,000 clicks (24%) Read > 30 seconds: 9,600 (40% of clicks) Follow / purchase: 1,900 (20% of readers) Every layer loses users Later stages are smaller To improve the final outcome, first identify the layer where users are stuck
Funnel model: a single change may affect only one layer, so metrics should be analysed by stage.

Retention is often shown as a retention curve: the horizontal axis is days since first use, and the vertical axis is the share returning that day. Flatter curves indicate stronger user stickiness; once two curves separate, the gap often widens over time.

Days since first use (days 1, 3, 7, 14 and 30) Retention rate Version B (after change) Version A (current) The curves separate from day 3 onward → the change may be having a real effect
Differences in retention curves often reveal more than a single-day figure.

Why do these metrics require A/B tests instead of simply comparing headline numbers? Four reasons:

  • Metrics contain sampling variation. CTR and retention are proportions and naturally vary from day to day; differences visible to the eye may be noise.
  • The effect to detect is often small. A two- to three-percentage-point lift from a headline change is already good performance and cannot be distinguished reliably by intuition.
  • Metrics can work against one another. CTR may rise while reading time and retention fall—optimising one metric alone can lead to poor decisions.
  • Only a randomised control design can separate the change from time, audience, season and other factors. This is precisely the problem addressed by the hypothesis testing and experiment design introduced earlier in this unit.
First separate metrics into two categories:Primary metrics determine whether to launch the change;guardrail metrics are limits that must not deteriorate, such as retention or complaint rate. Every funnel stage can be tested with an A/B test, but later stages have smaller samples and therefore require more traffic or experiment time.

Case Background and Two Metrics

  • Metric 1: Click-through rate = users who click ÷ users exposed. It is a proportion, so use a proportion test.
  • Metric 2: Average reading time after clicking is a continuous variable available only for users who clicked, so use a two-sample t-test.
  • Data fields: user ID, group (A/B), clicked (0/1) and reading time (seconds). The classroom version has 400 rows (200 per group), with a 4,000-row version demonstrating the effect of sample size.
Interactive Demonstration 5

A/B Test Workbench: Two Metrics, Two Tests

Switch data size to see how the same business difference yields different conclusions with 400 versus 4,000 rows. All statistics are calculated from the embedded raw data.

Data size:
Difference in click-through rate
Proportion-test z
One-tailed p-value
Reading-time t
Reading-time p-value

Conclusion and Four Pitfalls

The classroom version concludes that the new headline significantly improves CTR (15.5% → 24.5%, z = 2.25, one-tailed p = 0.0122), while reading time does not change significantly (95.0 → 92.7 seconds, t = −0.314, p = 0.754). The business recommendation is to retain the new headline while continuing to monitor reading time.

PitfallMeaningAction
Significant ≠ importantA statistically real difference may not justify a costly business changeAssess both lift and cost before launching
Sample-ratio mismatch (SRM)The allocation ratio deviates sharply from the design, indicating a problem with the experimentCheck assignment first; stop the experiment if the imbalance is severe
Multiple comparisonsWhen many metrics are tested simultaneously, at least one may appear “significant”Specify primary metrics in advance and treat the rest as supporting evidence
Novelty effectThe novelty of the new version fades over timeCover a full cycle and extend observation when necessary
With the same business logic and ten times the sample, the previously non-significant reading-time difference becomes significant (t = −3.53, p = 0.0004). The data did not change; the smaller sample simply lacked power to detect the difference.
Classroom Exercise 5

Write the Experiment Conclusion: Which Statements Are Correct?

The four statements below are common ways of reporting the result. Judge each as “sound” or “problematic,” then select Check.

2.5 Summary and Assignment

How to Choose a Test

QuestionData typeAppropriate method
Does one proportion reach a specified level?0/1 dataOne-sample proportion test
Do the proportions of two groups differ?0/1 data in two groupsTwo-sample proportion test
Does one group mean reach a specified level?Continuous dataOne-sample t-test
Do two group means differ?Independent continuous data in two groupsTwo-sample t-test (first assess variance similarity)
Did the same objects change from before to after?Paired continuous dataPaired t-test
  • Sampling distributions and the central limit theorem explain why the sample mean can be approximated by a normal distribution—the shared foundation of confidence intervals and tests.
  • Confidence intervals and hypothesis tests are two sides of the same result; reporting an interval conveys more information than a p-value alone.
  • The four-step procedure makes testing repeatable; when comparing groups, first determine whether the data are independent or paired.
  • Three reminders for A/B tests: significance is not importance, calculate sample size in advance, and specify the stopping rule beforehand.
Post-class assignment. Assignment 1: complete the four-step procedure for a one-tailed test of a fuel additive. Assignment 2: test the MBA mean age and conduct a paired t-test of pre- and post-training scores. Assignment 3: use AI to design an A/B experiment and analyse the case data. Submit a one-page conclusion, an AI-use statement and an AI-correction log. Unit 3 begins regression analysis, where significance will appear again.

Appendix: Interactive Demonstrations and Classroom Exercises

LocationTypeMeaning
2.1DemonstrationNormal-distribution workbench: μ, σ, standard score and left-tail probability
2.1DemonstrationCentral limit theorem: repeated sampling from 11,121 orders
2.1DemonstrationConfidence-interval workbench: repeated sampling and coverage
2.2DemonstrationDifference in means: heights of 771 male and 667 female athletes
2.4DemonstrationA/B workbench: 400 and 4,000 rows
2.2ExerciseFour-step procedure for the filling case
2.2ExerciseProportion test for the golf-course case
2.2ExerciseChoose a test for five scenarios
2.3ExerciseFind four problems in an AI experiment plan
2.4ExerciseFour ways to report an A/B conclusion

Data sources: S1_online_orders.xlsx (11,121 order values), Class2.Data\Athletes.xlsx (heights of 771 male and 667 female athletes), and 单元2_AB测试数据_自媒体.xlsx (400-row classroom version and 4,000-row demonstration version). A/B data are simulated with a fixed random seed and are reproducible; every statistic on the page is calculated from the original data.

Unit Glossary (English–Chinese)

English中文
Random variable随机变量
Normal distribution正态分布
Sampling distribution抽样分布
Central limit theorem中心极限定理
Standard error标准误
Confidence interval置信区间
Null hypothesis原假设
Significance level显著性水平
p-valuep 值
Type I error第一类错误
Statistical power检验功效