Business Analytics & Data Science

B04 · Intermediate

Descriptive and Inferential Statistics

10 lessons

B04 · Module 3, lesson 1 · Lesson 7 of 10

Hypothesis testing

Turn a business worry into a null and an alternative hypothesis, measure how surprising the data would be if nothing were wrong, and decide with a p-value or a critical value. Test Kilnworth’s 1 kg bags with a z test and a t test and September’s conversion against its target, then weigh Type I and Type II errors, power, practical significance and the traps of running many tests.

About 85 minutes

Before you start

You will be able to

  • State a null and an alternative hypothesis, one- or two-sided, for a business question, and choose the significance level before seeing the data.
  • Calculate a z or t statistic for a mean and a z statistic for a proportion, by hand and in Excel, and find the p-value that matches the alternative.
  • Decide with a p-value or a critical value, and write the conclusion in context without claiming more than the test shows.
  • Explain Type I and Type II errors and power, and calculate the power of a test and the sample size a chosen power needs.
  • Distinguish statistical from practical significance, and use a confidence interval to read a two-sided test.
  • Recognise p-hacking and multiple testing, and apply the American Statistical Association’s principles on p-values to a report.

Review first

Fictional case A fictional coffee business founded by Ana Lim. It starts as a catering and barista-training service, opens its own cafés and an online shop for beans, and plans a canned cold brew.

The idea

Fictional case

In October 2026 Ana weighed 40 of Kilnworth Roasting’s 1 kg bags of House Blend as they arrived. Kilnworth’s specification says its filling machine is set to 1,004 g with a standard deviation of 3 g; the normal-distribution lesson showed that a machine running to that specification puts about 9.1% of bags under the 1,000 g label. Ana’s 40 bags averaged 1,002.75 g, and 5 of them weighed less than 1,000 g. Before she writes to Kilnworth she wants to know whether 1,002.75 g is evidence that the machine fills light, or the kind of shortfall a sample of 40 would show by chance even if the machine were set exactly as promised.

The question a test answers

A hypothesis test turns that worry into a precise question. Start by assuming the dull explanation: the machine fills to 1,004 g on average, and Ana’s sample happens to be a little light. Then ask how surprising a sample mean of 1,002.75 g would be if that were true. If a result like hers would be rare, the dull explanation is hard to believe; if it would be common, the data give no reason to doubt it.

The dull explanation is the null hypothesis, written H0H_0 (“H-nought”). The claim you would need evidence for is the alternative hypothesis, H1H_1. With μ\mu (mu) standing for the mean fill of all the bags Kilnworth’s machine produces:

H0:μ=1,004 gH1:μ<1,004 gH_0: \mu = 1{,}004 \text{ g} \qquad H_1: \mu < 1{,}004 \text{ g}

The hypotheses are about the population mean, a parameter, never about the sample mean, a statistic: Ana already knows her sample averaged 1,002.75 g. The null contains the equality, and it is the hypothesis the test assumes while it does its sums. This alternative is one-sided because Ana’s concern is underfilling; the In depth section says when the two-sided alternative, μ ≠ 1,004 g, is the right choice. In B01’s terms both are a hypothesis, stated precisely enough for data to contradict it.

How far is 1,002.75 g from 1,004 g?

The sample mean is 1.25 g below the setting. Whether that is a lot depends on how much the means of samples of 40 bags vary, which is the standard error of the mean from the sampling-distributions lesson: s÷n=2.6563÷40≈0.4200s \div \sqrt{n} = 2.6563 \div \sqrt{40} \approx 0.4200 g, where ss = 2.66 g is the standard deviation of Ana’s 40 bags. The test statistic measures the gap in standard errors:

t=xˉ−μ0s/n=1,002.75−1,0042.6563/40=−1.250.4200≈−2.98t = \dfrac{\bar{x} - \mu_0}{s/\sqrt{n}} = \dfrac{1{,}002.75 - 1{,}004}{2.6563/\sqrt{40}} = \dfrac{-1.25}{0.4200} \approx -2.98

Ana’s sample mean sits almost three standard errors below the setting. If H₀ is true and bag weights are roughly normal, this statistic follows the t distribution with n − 1 = 39 degrees of freedom, the distribution the confidence-intervals lesson used for intervals. That tells us how often a value this far down would occur by chance alone.

The p-value

The p-value is the probability, calculated assuming H₀ is true, of a test statistic at least as extreme as the one observed, in the direction the alternative points. Here it is the area under the t curve with 39 degrees of freedom to the left of −2.98: =T.DIST(-2.976,39,TRUE) returns 0.0025. If the machine really averaged 1,004 g, only about 1 sample of 40 bags in 400 would come out this light or lighter.

The t distribution with 39 degrees of freedom: how the test statistic would vary from sample to sample if H₀ were true and the machine averaged 1,004 g. The lightly shaded lower tail beyond the critical value, −1.685, holds 5% of the area: the rejection region at α = 0.05. Ana’s t = −2.98 lies inside it, and the darker area to its left, 0.0025, is the p-value.

Small p-values are evidence against H₀. To decide, compare the p-value with the significance level α (alpha), the risk of rejecting a true null that you are prepared to run, chosen before seeing the data. The value 0.05 is a common convention, not a law. Ana chose α = 0.05; since 0.0025 ≤ 0.05 she rejects H₀: the data are evidence that the machine fills below its 1,004 g setting.

The steps of every test

  1. State the question, H₀, H₁ and α before looking at the results.
  2. Check the conditions the test needs: here a random sample of independent bags whose weights are roughly normal, or a sample large enough for the central limit theorem.
  3. Calculate the test statistic: how many standard errors the estimate lies from the null value.
  4. Find the p-value for the alternative, or compare the statistic with a critical value.
  5. Decide: reject H₀ if p ≤ α; otherwise fail to reject it.
  6. Conclude in the context of the question, with the size of the effect and an interval, not only the word “significant”.

For Ana’s bags, the normal-distribution lesson checked the shape: the 40 weights lie close to a normal curve, with no outliers. Independence needs more thought. Bags filled one after another can be alike if the machine drifts, and all 40 came from October’s deliveries, so the test describes the machine as it ran then, not for ever. If neighbouring bags are alike, s ÷ √n also understates the real standard error and the p-value comes out too small.

Step 6 matters as much as the arithmetic. Ana’s conclusion reads: “The 40 bags averaged 1,002.75 g, 1.25 g below the 1,004 g setting (95% confidence interval 1,001.90 to 1,003.60 g). A one-sided t test gives p = 0.0025, so a shortfall this large is unlikely to be chance: the machine appears to be filling light.” It doesn’t say the machine is broken, why it drifted, or that every delivery will be light.

In depth

Writing the hypotheses

The null hypothesis is the claim being checked, or the “no change, no difference” position: the specification, the target, last year’s average. It always contains the equality (=, ≤ or ≥), because the test needs one exact value to work out how the statistic behaves. For H₀: μ ≥ 1,004 g the test uses the boundary, 1,004 g, the case hardest to reject. The alternative is what the data would have to show, and it contains <, > or ≠.

Business questions as hypotheses
QuestionH₀H₁Sides
Are Kilnworth’s bags filled below the 1,004 g setting?μ=1,004\mu = 1{,}004 gμ<1,004\mu < 1{,}004 gOne (lower tail)
Is the average bag above the 1,000 g label?μ=1,000\mu = 1{,}000 gμ>1,000\mu > 1{,}000 gOne (upper tail)
Did the shop’s September conversion fall short of the 3.0% target?p=0.030p = 0.030p<0.030p < 0.030One (lower tail)
Has a hotel’s cleaning time per room changed from 30 minutes?μ=30\mu = 30 minμ≠30\mu \ne 30 minTwo

Choose one- or two-sided from the decision, before seeing the data. A one-sided test fits when only one direction would change what you do and the other would be treated like no difference: Ana acts on underfilling, while slightly heavy bags cost Kilnworth, not her. When either direction matters, use a two-sided test: a cleaning time that rose would break a hotel’s rota, and one that fell would free staff. Picking the side after seeing which way the data went, or switching to one-sided to get under 0.05, doubles the real chance of a false alarm.

“Fail to reject” is not “accept”. When p > α the test has found no convincing evidence against H₀, which can mean H₀ is true or that the sample was too small or too noisy to show a real difference. Report “no evidence of a difference at the 5% level”, with the interval, never “the test proved there is no difference”.

The z test when σ is known

If the population standard deviation σ\sigma (sigma) is known, the standard error is σ÷n\sigma \div \sqrt{n} and the statistic follows the standard normal distribution: a z test. Kilnworth’s specification states σ\sigma = 3 g. Taking that at its word, z=(1,002.75−1,004)÷(3÷40)=−1.25÷0.4743≈−2.64z = (1{,}002.75 - 1{,}004) \div (3 \div \sqrt{40}) = -1.25 \div 0.4743 \approx -2.64, and the one-sided p-value is =NORM.S.DIST(-2.635,TRUE) = 0.0042, again below 0.05.

The z test is less significant than the t test here because Kilnworth’s σ = 3 g is larger than Ana’s s = 2.66 g: its standard error is 0.474 g against 0.420 g, so the same 1.25 g shortfall is 2.64 standard errors rather than 2.98. A known σ is rare in business, and here it is only Kilnworth’s claim: if the machine has drifted, its spread may have changed too.

The one-sample t test uses Ana’s s and pays for the estimate with the t distribution’s heavier tails, so it needs no claim about σ. Some textbooks, OpenStax’s among them, switch from t to z once n reaches 30, using s in place of σ. Software uses t at every n, and so does this course: at n = 40 the normal curve would give 0.0015 for Ana’s t of −2.98 instead of 0.0025, the same decision with slightly overstated certainty.

P-values and critical values in Excel

Excel has no function for a one-sample t test: T.TEST compares two samples, as the comparing-means lesson shows. Calculate t from AVERAGE, STDEV.S and COUNT, then take the p-value from the function that matches the alternative.

Excel functions for the p-value of a z or t statistic
Alternativep-value of a t statisticp-value of a z statistic
H1:μ<μ0H_1: \mu < \mu_0 (lower tail)=T.DIST(t,df,TRUE)=NORM.S.DIST(z,TRUE)
H1:μ>μ0H_1: \mu > \mu_0 (upper tail)=T.DIST.RT(t,df)=1-NORM.S.DIST(z,TRUE)
H1:μ≠μ0H_1: \mu \ne \mu_0 (both tails)=T.DIST.2T(ABS(t),df)=2*(1-NORM.S.DIST(ABS(z),TRUE))

T.DIST is Excel’s left-tailed t distribution (with TRUE for the cumulative probability; FALSE gives the height of the curve, which is not a probability) and T.DIST.RT its right tail. T.DIST.2T returns #NUM! for a negative x, so wrap the statistic in ABS. For Ana’s bags, =T.DIST.2T(ABS(-2.976),39) gives the two-sided p-value 0.0050, twice the one-sided 0.0025.

The critical value approach reaches the same decision without a p-value. The rejection region is the set of statistics extreme enough to reject H₀ at level α. For a one-sided lower-tail t test with 39 degrees of freedom it is t below =T.INV(0.05,39) = −1.685; for a two-sided test at 5% it is |t| above =T.INV.2T(0.05,39) = 2.023. Ana’s −2.98 lies beyond both. For z the familiar values are 1.645 (one-sided, 5%) and 1.96 (two-sided, 5%).

A p-value says more than the decision. A t of −2.98 and a t of −1.70 both lie beyond −1.685, so both reject at 5%, but the first would happen by chance about 1 time in 400 and the second about 1 time in 20: very different strengths of evidence. Report the p-value, not only “significant” or “not significant”.

Z.TEST’s one-tailed quirk

Excel’s Z.TEST(array, x, [sigma]) returns a one-tailed p-value, and always the upper tail. Microsoft defines it as 1 − NORM.S.DIST((AVERAGE(array) − x) ÷ (sigma ÷ √n), TRUE): the probability of a sample mean above the observed one if the population mean is x. For a sample mean below x the result is above 0.5. For Ana’s bags in B2:B41, =Z.TEST(B2:B41,1004,3) returns 0.9958.

The p-value for her lower-tail alternative is =1-Z.TEST(B2:B41,1004,3) = 0.0042, the z test’s result above. For a two-sided test Microsoft gives =2*MIN(Z.TEST(B2:B41,1004,3),1-Z.TEST(B2:B41,1004,3)), here 0.0084. Leave out sigma and Z.TEST uses the sample standard deviation but still the normal distribution, so it is still a z test, not a t test.

Testing a proportion

The same logic tests a proportion against a stated value p0p_0. Under H₀ the sample proportion p^\hat{p} (“p-hat”) has standard error p0(1−p0)÷n\sqrt{p_0(1 - p_0) \div n}, built from the null’s own value because the test asks how the data would behave if H₀ were true; a confidence interval uses p^\hat{p}, because it has no null value. The one-proportion z test statistic is z=(p^−p0)÷p0(1−p0)÷nz = (\hat{p} - p_0) \div \sqrt{p_0(1 - p_0) \div n}, compared with the standard normal. The normal model needs np0np_0 and n(1−p0)n(1 - p_0) both at least 10, a common rule of thumb (OpenStax’s version asks that “the sample proportion, p′, times the sample size is greater than 5” and that “1-p′ times the sample size is also greater than 5”), and independent trials.

In September the shop, web and app together and the basis of B01’s target, took 251 orders from 11,400 visits: a conversion rate of 2.20% against Ana’s 3.0% target. The applied example works the test: z ≈ −5.00, with a p-value of about 2.9 × 10⁻⁷. Two cautions apply to any test on visits. Visits are not fully independent trials, because one person can visit several times; and the test only says the shortfall is too large to be chance, not what caused it. Comparing the website’s August with its September needs a two-proportion test, which the proportions-and-chi-square lesson teaches.

Two ways to be wrong

A test decides between two hypotheses from incomplete information, so it can go wrong in two ways. A Type I error rejects a true null: a false alarm. A Type II error fails to reject a false null: a missed effect. The significance level α is the probability of a Type I error when H₀ is true; β (beta) is the probability of a Type II error for a particular true value of the parameter.

The four outcomes of Ana’s test
DecisionH₀ true: the machine averages 1,004 gH₀ false: the machine fills light
Reject H₀Type I error (probability α): Ana complains about a machine that is fineRight decision (probability 1 − β, the power): the underfill is caught
Fail to reject H₀Right decision (probability 1 − α)Type II error (probability β): customers keep getting light bags

The two errors trade off. Lowering α to 0.01 makes false alarms rarer but makes a real underfill harder to detect, raising β. Which error costs more is a business judgement: a false complaint costs some goodwill with a supplier and an engineer’s visit, while a missed underfill costs Ana’s customers coffee and, as more bags fall under the label, her reputation. Those costs, not convention, should set α.

Power, and what raises it

The power of a test is 1−β1 - \beta: the probability that it rejects H₀ when a particular alternative is true. It depends on the size of the true difference δ\delta (delta), the spread σ\sigma, the sample size nn, the significance level and whether the test is one- or two-sided. For a one-sided z test, power =Φ(∣δ∣÷(σ÷n)−z1−α)= \Phi(|\delta| \div (\sigma \div \sqrt{n}) - z_{1-\alpha}), where Φ\Phi is the standard normal cumulative probability, NORM.S.DIST(…, TRUE).

Suppose the machine really averages 1,003 g, 1 g below the setting. With σ\sigma = 3 g, n = 40 and α = 0.05 one-sided, the standard error is 0.474 g, so the true mean sits 1÷0.474≈2.111 \div 0.474 \approx 2.11 standard errors below the null value, and power =Φ(2.11−1.645)=Φ(0.46)≈0.68= \Phi(2.11 - 1.645) = \Phi(0.46) \approx 0.68. Forty bags would catch a 1 g underfill about two times in three. They would catch a 0.5 g underfill only 28% of the time, and a 2 g underfill 99% of the time.

  • A larger sample: the standard error shrinks with √n.
  • A larger true difference: big effects are easier to see than small ones.
  • Less noise: a smaller σ, from more precise scales or more uniform conditions.
  • A larger α: a lenient threshold rejects more often, at the price of more false alarms.
  • A one-sided test, when the effect lies in the direction tested; it can never detect one in the other direction.

Turned round, the formula gives the sample size for a chosen power: n=((z1−α+z1−β) σ÷δ)2n = ((z_{1-\alpha} + z_{1-\beta})\,\sigma \div \delta)^2, rounded up, with z1−α/2z_{1-\alpha/2} in place of z1−αz_{1-\alpha} for a two-sided test. Use it before collecting data, from the smallest difference worth detecting; the challenging example plans Ana’s next check. The formula treats σ\sigma as known, and for a t test the NIST/SEMATECH handbook repeats the calculation once with t values, which adds a bag or two.

Statistical and practical significance

A result is statistically significant when its p-value is at or below α. That says the effect is unlikely to be chance alone; it says nothing about whether the effect is large enough to matter. The American Statistical Association’s 2016 statement on p-values makes this its fifth principle: a p-value measures neither the size of an effect nor its importance.

With enough data, trivial differences become significant. If Ana weighed 4,000 bags and found a mean of 1,003.9 g, then with σ\sigma = 3 g, z=−0.1÷(3÷4,000)≈−2.11z = -0.1 \div (3 \div \sqrt{4{,}000}) \approx -2.11 and p ≈ 0.018: significant at 5%, for a tenth of a gram. In the other direction, a small sample can miss an important effect. Report the estimate and its interval, and judge practical significance by what the difference does to the business.

For the bags, practical significance comes through the label. A machine averaging 1,002.75 g with σ = 3 g would put about 18% of bags under 1,000 g, =NORM.DIST(1000,1002.75,3,TRUE), roughly twice the 9.1% of the specification. A shortfall of 1.25 g is about 0.1% of the coffee in a bag, but it doubles the share of light bags, and light bags are what customers notice.

Intervals and tests

A two-sided test at level α and a (1 − α) confidence interval are two views of one calculation: a two-sided t test at 5% rejects H₀: μ = μ₀ exactly when μ₀ lies outside the 95% t interval. Ana’s 95% interval for the mean fill is 1,001.90 to 1,003.60 g. Both 1,004 g and 1,000 g lie outside it, so two-sided tests reject both (p = 0.0050 and p < 0.0001), while 1,003 g lies inside and would not be rejected.

Ana’s 95% confidence interval for the mean fill, 1,001.90 to 1,003.60 g. A two-sided t test at 5% rejects any hypothesised mean outside the interval, such as the 1,004 g setting and the 1,000 g label, and no value inside it, such as 1,003 g.

The interval says more than the test. The machine’s mean is plausibly between 0.40 g and 2.10 g below its setting, which is the range Ana should keep in mind when she judges whether the shortfall matters. A one-sided test at 5% matches a one-sided 95% bound instead: here the mean is below 1,003.46 g with 95% confidence.

P-hacking and multiple testing

Every test at α = 0.05 has a 5% chance of a false alarm when H₀ is true. Run many tests and false alarms become likely: with 20 independent tests of true nulls, the chance of at least one p ≤ 0.05 is 1 − 0.95²⁰ ≈ 0.64, and one false positive is expected. This is the problem of multiple testing. Testing every metric on a dashboard each month, or every customer segment, will produce “significant” findings that are noise.

P-hacking is the deliberate or careless version: trying analyses until one gives p below 0.05, and reporting that one. Its common forms are testing many outcomes or subgroups, adding data and retesting until the result crosses the line, dropping awkward values, and choosing one-sided after seeing the data. Each makes the reported p-value smaller than the real chance of a false alarm.

In 2016 the American Statistical Association published a statement on p-values (Wasserstein and Lazar) with six principles. In paraphrase, except the fifth, which is quoted:

  1. A p-value can show how incompatible the data are with a stated statistical model, such as one in which H₀ is true.
  2. P-values do not measure the probability that the studied hypothesis is true, or the probability that the data arose by chance alone.
  3. Scientific conclusions and business or policy decisions should not rest only on whether a p-value passes a threshold such as 0.05.
  4. Proper inference requires full reporting and transparency: how many hypotheses were explored, which analyses were run and every p-value calculated, not only the significant ones.
  5. “A p-value, or statistical significance, does not measure the size of an effect or the importance of a result.”
  6. By itself a p-value is not a good measure of evidence about a model or hypothesis: a p-value near 0.05 is only weak evidence against the null, and a large p-value is not evidence for it.

The defences are habits. Write down the question, the hypotheses, α and the analysis before looking at the results; report every test you ran; treat a surprising result from one of many tests as a lead to check with new data. When you must test several things at once, make each test stricter: the simplest adjustment, Bonferroni’s, tests each of k hypotheses at α ÷ k, and the anova lesson explains the family-wise error rate behind it.

Formulas

z test for a mean (σ known)

z=xˉ−μ0σ/nz = \dfrac{\bar{x} - \mu_0}{\sigma / \sqrt{n}}
xˉ\bar{x}
Sample meanunits of x
μ0\mu_0
The population mean under the null hypothesisunits of x
σ\sigma
Known population standard deviationunits of x
nn
Sample size
zz
Test statistic, compared with the standard normal distribution

Assumes. A random sample of independent values; σ known; the population roughly normal, or n large enough for the central limit theorem.

Excel: Z.TEST(array, μ₀, σ) returns 1 − NORM.S.DIST(z, TRUE), the upper-tail p-value only.

One-sample t test for a mean

t=xˉ−μ0s/n,df=n−1t = \dfrac{\bar{x} - \mu_0}{s / \sqrt{n}}, \qquad \text{df} = n - 1
xˉ\bar{x}
Sample meanunits of x
μ0\mu_0
The population mean under the null hypothesisunits of x
ss
Sample standard deviation (STDEV.S)units of x
nn
Sample size
tt
Test statistic, compared with the t distribution
df\text{df}
Degrees of freedom

Assumes. A random sample of independent values from a roughly normal population; for larger n, moderate skew is tolerable.

Excel has no one-sample T.TEST: compute t, then T.DIST, T.DIST.RT or T.DIST.2T.

One-proportion z test

z=p^−p0p0(1−p0)/nz = \dfrac{\hat{p} - p_0}{\sqrt{p_0 (1 - p_0) / n}}
p^\hat{p}
Sample proportion: successes ÷ trials
p0p_0
The proportion under the null hypothesis
nn
Number of trials
zz
Test statistic, compared with the standard normal distribution

Assumes. Independent trials with the same probability; np₀ and n(1 − p₀) at least 10.

The standard error uses p₀, not p̂: the test works out how p̂ would vary if the null were true.

The p-value for each alternative

lower: Pr⁡(T≤t),upper: Pr⁡(T≥t),two-sided: 2Pr⁡(T≥∣t∣)\text{lower: } \Pr(T \le t), \qquad \text{upper: } \Pr(T \ge t), \qquad \text{two-sided: } 2\Pr(T \ge |t|)
TT
The statistic’s distribution if the null hypothesis is true (t with n − 1 df, or the standard normal)
tt
The statistic calculated from the sample

Excel: T.DIST(t, df, TRUE), T.DIST.RT(t, df) and T.DIST.2T(ABS(t), df); NORM.S.DIST(z, TRUE) for z.

Power of a one-sided z test

1−β=Φ ⁣(∣δ∣σ/n−z1−α)1 - \beta = \Phi\!\left(\dfrac{|\delta|}{\sigma/\sqrt{n}} - z_{1-\alpha}\right)
1−β1 - \beta
Power: the probability of rejecting the null when the true difference is δ
δ\delta
True mean minus the null valueunits of x
σ\sigma
Population standard deviationunits of x
nn
Sample size
z1−αz_{1-\alpha}
Standard normal value with α above it (1.645 for α = 0.05)
Φ\Phi
Standard normal cumulative probability, NORM.S.DIST(…, TRUE)

Assumes. The effect lies in the direction tested.

For a two-sided test use z₁₋α/₂ (1.96 for α = 0.05); the tiny chance of rejecting in the wrong tail is ignored.

Sample size for a chosen power

n=((z1−α+z1−β) σδ)2n = \left(\dfrac{(z_{1-\alpha} + z_{1-\beta})\,\sigma}{\delta}\right)^{2}
nn
Sample size needed, rounded up
z1−αz_{1-\alpha}
Standard normal value for the significance level (z₁₋α/₂ if two-sided)
z1−βz_{1-\beta}
Standard normal value for the power (0.842 for 80%)
σ\sigma
Planning value of the standard deviationunits of x
δ\delta
Smallest difference worth detectingunits of x

With a t test, recalculate once with t values for n − 1 degrees of freedom (NIST/SEMATECH 7.2.2.2).

Chance of at least one false alarm in k tests

Pr⁡(at least one false alarm)=1−(1−α)k\Pr(\text{at least one false alarm}) = 1 - (1 - \alpha)^{k}
α\alpha
Significance level of each test
kk
Number of independent tests, each of a true null hypothesis

Bonferroni’s adjustment tests each at α ÷ k, which keeps this chance at or below α.

Worked examples

A first example: A two-sided t test: cleaning times at a hotel

Fictional figures

Oakhaven Hotel’s housekeeping rota allows 30 minutes to clean a room, the average with its old cleaning trolley. In a trial of a new cleaning trolley, a supervisor timed 12 rooms chosen at random over a week (minutes): 27, 32, 25, 29, 24, 31, 28, 34, 27, 25, 29 and 30, in B2:B13. Test at α = 0.05 whether the mean time with the new trolley differs from 30 minutes.

  1. Hypotheses, set before timing anything: H₀: μ = 30 minutes, H₁: μ ≠ 30 minutes. Two-sided, because a slower trolley would break the rota and a faster one would free staff; either would change the plan.
  2. Conditions: the rooms were chosen at random and timed separately, and the 12 times show no outlier and no strong skew (median 28.5, mean 28.42), so a t test is reasonable for this small sample.
  3. Statistic: =AVERAGE(B2:B13) = 28.42 and =STDEV.S(B2:B13) = 3.029, so SE =3.029÷12=0.874= 3.029 \div \sqrt{12} = 0.874 and t=(28.42−30)÷0.874≈−1.81t = (28.42 - 30) \div 0.874 \approx -1.81, with 11 degrees of freedom.
  4. P-value, two-sided: =T.DIST.2T(ABS(-1.811),11) = 0.098. Equivalently, |t| = 1.81 is below the critical value =T.INV.2T(0.05,11) = 2.201.
  5. Decision: 0.098 > 0.05, so fail to reject H₀. The 95% interval, 28.417±2.201×0.87428.417 \pm 2.201 \times 0.874, runs from 26.49 to 30.34 minutes and includes 30.

Answer. Fail to reject H₀ at the 5% level: t ≈ −1.81 with 11 df, two-sided p ≈ 0.098; 95% interval 26.49 to 30.34 minutes.

What it means. The trial gives no convincing evidence that the trolley changes cleaning time, which is not the same as showing it has no effect: the interval allows anything from a saving of about 3.5 minutes a room to an extra 0.3 minutes. A one-sided test would have given p = 0.049, but the supervisor chose two-sided before timing anything, and switching now because the data happened to fall low would turn a 5% test into a 10% one. A larger trial would pin the effect down.

A harder example: How many bags should Ana weigh?

Fictional figures

Kilnworth agrees to recalibrate the machine, and Ana will check the next delivery. She wants an 80% chance of detecting a 1 g underfill (a true mean of 1,003 g) with a one-sided test at α = 0.05, taking σ = 3 g from the specification. Did her 40 bags have that power? How many bags does 80% power need, how many for a two-sided test, and how many to detect a 0.5 g underfill?

  1. Power with 40 bags: SE =3÷40=0.474= 3 \div \sqrt{40} = 0.474 g, so the true mean is 1÷0.474=2.111 \div 0.474 = 2.11 standard errors below 1,004 g, and power =Φ(2.11−1.645)=Φ(0.463)≈0.678= \Phi(2.11 - 1.645) = \Phi(0.463) \approx 0.678: =NORM.S.DIST(1/(3/SQRT(40))-NORM.S.INV(0.95),TRUE). So β ≈ 0.32, and about one check in three would miss a real 1 g underfill.
  2. 80% power, one-sided: z0.95=1.6449z_{0.95} = 1.6449 and z0.80=0.8416z_{0.80} = 0.8416, so n=((1.6449+0.8416)×3÷1)2=7.45942≈55.64n = ((1.6449 + 0.8416) \times 3 \div 1)^2 = 7.4594^2 \approx 55.64, rounded up to 56 bags.
  3. Two-sided at 5%: replace 1.6449 with 1.9600: n=((1.9600+0.8416)×3)2≈70.64n = ((1.9600 + 0.8416) \times 3)^2 \approx 70.64, so 71 bags. A two-sided test splits α between the tails, so it needs more data for the same power in one direction.
  4. A 0.5 g underfill: halving δ\delta quadruples n, ((1.6449+0.8416)×3÷0.5)2≈222.6((1.6449 + 0.8416) \times 3 \div 0.5)^2 \approx 222.6, so 223 bags; 40 bags would catch it only 28% of the time.
  5. With the t test Ana will actually run, the NIST handbook’s one iteration, using t values with 55 degrees of freedom (from n = 56), gives n ≈ 57.2, so 58 bags: a little more than the normal approximation.

Answer. Her 40 bags had about 68% power for a 1 g underfill. 80% power needs 56 bags one-sided (58 with the t iteration), 71 two-sided, and 223 to detect 0.5 g.

What it means. Power is planned from the smallest difference worth catching. A 1 g underfill matters to Ana because it raises the share of bags under the label from 9.1% to about 16%, so she decides to weigh 60 bags next time. Detecting 0.5 g would mean weighing more than 200 bags a delivery, more effort than that difference is worth to her. A test too small to detect the difference that matters wastes the effort spent on it, so plan n before collecting.

Applied: a business decision: Did September’s conversion really fall short?

Fictional figures

B01’s figures for the whole shop, web and app together, which is the basis of Ana’s 3.0% conversion target. In September, the month after the website’s checkout redesign of 1 September, the shop took 251 orders from 11,400 visits (2.20%). In October, when a fix for a payment-page bug on mobile browsers was released on 5 October, it took 319 orders from 11,000 visits (2.90%). For each month, test at α = 0.05 whether the shop’s conversion rate was below 3.0%, and say what the results do and don’t tell her.

  1. Hypotheses (the same for both months): H₀: p = 0.030 and H₁: p < 0.030, where p is the month’s underlying conversion rate per visit. One-sided, because Ana’s question is whether the month fell short.
  2. Conditions: for September np₀ = 11,400 × 0.03 = 342 and n(1 − p₀) = 11,058, for October 330 and 10,670, all far above 10. Visits are treated as independent trials, which repeat visitors make only approximately true.
  3. September: p^=251÷11,400=0.022018\hat{p} = 251 \div 11{,}400 = 0.022018; the standard error under H₀ is 0.03×0.97÷11,400=0.0015977\sqrt{0.03 \times 0.97 \div 11{,}400} = 0.0015977; z=(0.022018−0.030)÷0.0015977≈−5.00z = (0.022018 - 0.030) \div 0.0015977 \approx -5.00; p = =NORM.S.DIST(-4.996,TRUE) ≈ 2.9 × 10⁻⁷.
  4. October: p^=319÷11,000=0.0290\hat{p} = 319 \div 11{,}000 = 0.0290; the standard error is 0.03×0.97÷11,000=0.0016265\sqrt{0.03 \times 0.97 \div 11{,}000} = 0.0016265; z=(0.0290−0.030)÷0.0016265≈−0.61z = (0.0290 - 0.030) \div 0.0016265 \approx -0.61; p = =NORM.S.DIST(-0.615,TRUE) ≈ 0.27.
  5. Decisions: reject H₀ for September; fail to reject H₀ for October.

Answer. September: z ≈ −5.00 and p ≈ 2.9 × 10⁻⁷, strong evidence that the shop’s conversion rate was below 3.0%. October: z ≈ −0.61 and p ≈ 0.27, no evidence that it was below target.

What it means. October’s 2.90% is the kind of miss a month of 11,000 visits produces by chance even when the true rate is 3.0%, so on its own it is no warning sign; the data are compatible with the shop being back on target after the fix. September’s fall is far too large for chance. The test doesn’t say why: the checkout redesign is the obvious suspect, but B01’s warning about causation applies, and the formal comparison of the website’s August and September is the two-proportion test in the proportions-and-chi-square lesson.

Explore

The t distribution with 39 degrees of freedom, with Ana’s statistic t = −2.976 and the 5% rejection region in the lower tail. Switch to “Both tails” to see the two-sided p-value, 0.0050, and compare the dashed standard normal curve, whose tails are thinner.

Loading the interactive…

Ana’s 40 bags with the whole test written as formulas. Change the hypothesised mean in E1 to 1000, then to 1003, and watch t, the three p-values and Z.TEST move while the 95% interval stays put; 1,003 g lies inside it, so no test rejects it at 5%. Turn on Show formulas to see T.DIST, T.DIST.RT, T.DIST.2T and Z.TEST.

Loading the interactive…

The distribution of the sample mean if the machine averages 1,004 g (H₀) and if it really averages 1,003 g, with σ = 3 g. Raise n to 56 to reach 80% power, shrink the true difference to 0.5 g, or change α and the alternative, and watch α, β and the power trade off.

Loading the interactive…

Common mistakes

  • “p = 0.0025, so there is a 0.25% chance the machine is fine.”

    The p-value is calculated assuming the machine is fine: it is the chance of data at least this extreme in that world, not the chance of that world given the data. The ASA’s second principle says exactly this. To put a probability on a hypothesis you need Bayes’ rule and prior probabilities, which a test doesn’t use.

  • “We failed to reject H₀, so the trolley makes no difference.”

    Failing to reject means the data are compatible with no difference; they may be compatible with a useful difference too. Oakhaven’s interval runs from a saving of 3.5 minutes to an extra 0.3: that is a lack of evidence, not evidence of no effect. Report the interval and, if it matters, the power.

  • “=Z.TEST(B2:B41,1004,3) is 0.9958, so there is no evidence of underfilling.”

    Z.TEST always returns the upper-tail p-value. For a lower-tail alternative the p-value is =1-Z.TEST(B2:B41,1004,3) = 0.0042; for two-sided, =2*MIN(Z.TEST(…),1-Z.TEST(…)). Check which tail every function reports before you read its result.

  • “Two-sided p is 0.098, but one-sided it’s 0.049, so it’s significant.”

    The side belongs to the question and must be fixed before the data are seen. Choosing it afterwards, in whichever direction the data fell, doubles the real false-alarm rate. Halving a two-sided p-value is legitimate only for a one-sided question stated in advance.

  • “Significant, so it matters.”

    With 4,000 bags a 0.1 g shortfall would be significant and meaningless. Significance says an effect is unlikely to be chance alone; its size, its interval and its consequences (here, the share of bags under the label) say whether it matters.

  • “We tested 20 product lines and one was significant: we found something.”

    With 20 tests of true nulls at 5%, one false positive is expected and the chance of at least one is about 64%. Report all 20 tests, treat the one as a lead to check with new data, or test each at a stricter level such as α ÷ 20.

Guided practice

Work through these with hints when you need them. Every hint and every worked solution is there to be used.

Loading four questions…

On your own

No hints this time. Answer, check, and read the feedback; the solution appears once you have answered or if you ask for it. Your first answers count toward mastery.

Loading six questions…

In practice

Fictional case

Ana writes to Kilnworth: “In October I weighed 40 of your 1 kg House Blend bags. They averaged 1,002.75 g (95% confidence interval 1,001.90 to 1,003.60 g), about 1.25 g below your stated 1,004 g setting; a one-sided t test gives p = 0.0025, so a shortfall this large is very unlikely to be chance. The average is still above 1,000 g, but 5 of the 40 bags were under the label. Could you check the machine’s setting? I will weigh 60 bags from the next delivery to confirm.” She keeps the spreadsheet, so that the next check is run the same way.

Notice what she leaves out. She doesn’t say the machine is proven faulty, or that there is a 99.75% chance it is: neither follows from a p-value. She reports the estimate, the interval and the p-value together, plans a check with enough power to confirm the finding, and asks a question rather than making an accusation. The test shows the bags are light on average; it doesn’t show why, and a test about the mean says nothing directly about individual bags, which is why she mentions the five under the label.

The same pattern runs through business uses of testing: checks against a specification, a month’s KPI against its target, before-and-after comparisons and A/B tests. Good practice is the same in each. State the hypotheses and α in advance, setting α from the costs of each error; plan the sample size from the smallest difference that matters; check the conditions; report the estimate, its interval and the p-value; and treat p-values near α as weak evidence that deserves a second look with new data.

Targets need one more caution. A target is a goal, not a fact about the world, so testing a month against it asks only whether the shortfall is larger than chance would produce. October’s conversion was 0.1 points below 3.0% with p = 0.27, which is noise; September’s was 0.8 points below with a p-value near zero, which is not. A dashboard that turns every month below target red, without asking how big a miss chance alone produces, will send Ana chasing noise.

Knowledge check

Six questions, one attempt each, no hints. Score 80% or more to complete the lesson; you can take it again at any time.

Loading six questions…

Summary

  • A test assumes the null hypothesis H₀ (the specification, the target, no difference) and asks how surprising the data would be; the alternative H₁ is what needs evidence. Choose one- or two-sided, and α, before seeing the data.
  • t = (x̄ − μ₀) ÷ (s ÷ √n) with n − 1 degrees of freedom; a z test uses a known σ; for a proportion, z = (p̂ − p₀) ÷ √(p₀(1 − p₀) ÷ n).
  • The p-value is the probability, if H₀ is true, of a statistic at least as extreme as the one observed: =T.DIST(t,df,TRUE), =T.DIST.RT(t,df) or =T.DIST.2T(ABS(t),df). Reject H₀ when p ≤ α, or when the statistic is beyond the critical value.
  • Z.TEST returns the upper-tail p-value only: use 1 − Z.TEST for a lower-tail alternative and 2 × MIN(Z.TEST, 1 − Z.TEST) for two-sided.
  • A p-value is not the probability that H₀ is true; failing to reject is not accepting; significance is not importance.
  • A Type I error rejects a true H₀ (probability α); a Type II error misses a real effect (β). Power, 1 − β, rises with n, the true difference and α, and falls with σ: plan n from the smallest difference that matters.
  • A two-sided test at 5% rejects μ₀ exactly when μ₀ lies outside the 95% interval; report the interval with the p-value.
  • Many tests make false alarms likely (64% for 20 tests at 5%): fix the analysis in advance, report every test, and confirm surprises with new data.

Key formulas

Terms introduced

Null hypothesis
In a hypothesis test, the statement assumed true while the test is calculated, usually “no difference” or “as specified”. It contains an equality (=, ≤ or ≥) and is written H₀.
Alternative hypothesis
The statement a hypothesis test looks for evidence for, contradicting the null hypothesis. It contains <, > or ≠ and is written H₁ (or Hₐ).
Test statistic
A number calculated from the sample that measures how far the data lie from what the null hypothesis predicts, usually in standard errors: z, t, χ² or F.
Significance level
The probability of rejecting a true null hypothesis that a test is designed to allow, chosen before the data are seen; written α, often 0.05.
Critical value
A value of a test statistic’s distribution that cuts off a chosen tail area. A test rejects the null hypothesis when the statistic lies beyond it; a confidence interval uses it as its multiplier (1.96 for a 95% z interval).
Rejection region
The values of the test statistic for which the null hypothesis is rejected at the chosen significance level: those beyond the critical value or values.
One-sided test
A hypothesis test whose alternative points in one direction (< or >), so the p-value comes from one tail. Also called a one-tailed test.
Two-sided test
A hypothesis test whose alternative is ≠, so values far from the null in either direction count as evidence and the p-value comes from both tails. Also called a two-tailed test.
z test
A test whose statistic follows the standard normal distribution if the null hypothesis is true: for a mean with a known population standard deviation, z = (x̄ − μ₀) ÷ (σ ÷ √n).
One-sample t test
A test of whether a population mean equals a stated value, using t = (x̄ − μ₀) ÷ (s ÷ √n) and the t distribution with n − 1 degrees of freedom.
One-proportion z test
A test of whether a population proportion equals a stated value p₀, using z = (p̂ − p₀) ÷ √(p₀(1 − p₀) ÷ n) and the standard normal distribution.
Type I error
Rejecting a null hypothesis that is true: a false alarm. Its probability, when the null is true, is the significance level α.
Type II error
Failing to reject a null hypothesis that is false: a missed effect. Its probability, β, depends on how far the truth is from the null.
Power
The probability that a test rejects the null hypothesis when a particular alternative is true, 1 − β. It rises with the sample size, the true difference and the significance level, and falls as the spread grows.
Statistically significant
Describes a result whose p-value is at or below the chosen significance level, so it is unlikely under the null hypothesis. It says nothing about whether the effect is large or important.
Practical significance
Whether an effect is large enough to matter for a decision, judged from its estimated size and interval in the units of the problem, not from its p-value.
Multiple testing
Running many hypothesis tests on the same data or question, which makes at least one false alarm likely even when every null hypothesis is true.
P-hacking
Trying analyses (outcomes, subgroups, exclusions, stopping points, one tail or two) until one gives a significant p-value and reporting that one, which makes the reported p-value misleadingly small.

Sources

  1. Holmes, A., Illowsky, B. & Dean, S. (2023). Introductory Business Statistics 2e, chapter 9, “Hypothesis Testing with One Sample” (sections 9.1–9.4). OpenStax. openstax.org/books/introductory-business-statistics/pages/9-…
  2. Wasserstein, R. L. & Lazar, N. A. (2016). “The ASA’s statement on p-values: context, process, and purpose”. The American Statistician, 70(2), 129–133. doi.org/10.1080/00031305.2016.1154108
  3. Microsoft Support. “Z.TEST function”. support.microsoft.com/en-US/excel/functions/z-test-function
  4. Microsoft Support. “T.DIST function”. support.microsoft.com/en-US/excel/functions/t-dist-function
  5. Microsoft Support. “T.DIST.2T function”. support.microsoft.com/en-US/excel/functions/t-dist-2t-functi…
  6. Microsoft Support. “T.INV.2T function”. support.microsoft.com/en-US/excel/functions/t-inv-2t-functio…
  7. NIST/SEMATECH. e-Handbook of Statistical Methods, sections 7.2.2, “Are the data consistent with the assumed process mean?”, and 7.2.2.2, “Sample sizes required”. itl.nist.gov/div898/handbook/prc/section2/prc222.htm