Hypothesis testing, Z-test & t-test
Hypothesis testing is a formal procedure for making decisions about population parameters based on sample data, and is one of the most common tools available to engineers and scientists for making data-driven decisions. It provides a rigorous, systematic framework for drawing conclusions from sample data, allowing us to move beyond intuition and subjective judgment to conclusions supported by mathematical evidence.
Specifically, a hypothesis test is a procedure that answers the question: “Did these data come from a particular type of distribution?” or “Is there a significant difference between groups?” The most common hypothesis test determines whether a sample mean could have come from a population with a specified mean.
Components of hypothesis testing
Every hypothesis test involves two competing hypotheses:
Null hypothesis (): The statement being tested, typically representing “no effect” or “no difference.” For example: , i.e. the mean of a distribution is the mean of the sample.
Alternative hypothesis ( or ): The statement we conclude if we reject the null hypothesis. It can be:
- Two-tailed:
- Left-tailed:
- Right-tailed:
Types of errors
There are four possible outcomes, which are the combinations of whether is true or note and whether was retained or rejected, where the two “incorrect” outcomes are considered “errors” of two types, where type I is a false positive and type II is a false negative:
| True | False | |
|---|---|---|
| Reject | Type I Error () | Correct Decision (Power = ) |
| Retain | Correct Decision | Type II Error () |
Type I error (false positive): Rejecting when it is actually true. The probability of a Type II error is .
Type II error (false negative): Failing to reject when it is actually false. The probability of a Type II error is .
The power of a test is the probability of correctly rejecting a false null hypothesis: Power = .
The hypothesis testing procedure
Step 1: State the null and alternative hypotheses.
Step 2: Choose the significance level α (commonly 0.05 or 0.01).
Step 3: Determine whether to use a one-tail or two-tail test:
- If testing whether the parameter has changed (in either direction), use a two-tail test
- If testing whether the parameter has increased or decreased (one direction only), use a one-tail test
Step 4: Find the critical value(s) from the appropriate table (-table or -table) based on α and the number of tails.
Step 5: Calculate the test statistic from the sample data.
Step 6: Make a decision:
- If |test statistic| ≥ critical value, reject H₀
- If |test statistic| < critical value, fail to reject H₀
Confidence levels
The results of experiments are seldom correct 100% of the time. Recognizing this fundamental reality, researchers accept a certain probability of being wrong. In order to minimize this probability, an experiment is repeated several times. The number of repetitions required depends on the level of confidence wanted in the results.
For example, if the results have a 5% probability of being wrong, the confidence level, denoted C, is 95% that the results are correct. Common confidence levels used in practice include 90%, 95%, and 99%. The choice of confidence level depends on the consequences of making an incorrect decision and the practical constraints of the situation. Higher confidence levels require more data or result in wider confidence intervals.
The significance level (denoted ) represents the probability of making an error—specifically, the probability of rejecting a true hypothesis. The relationship between confidence level and significance level is:
For a 95% confidence level, α = 0.05, meaning there is a 5% chance of incorrectly rejecting a true hypothesis.
The -test
The z-test is used when:
- The population standard deviation σ is known, OR
- The sample size is large (typical rule of thumb: ), allowing the sample standard deviation to approximate .
The -test statistic
The test statistic for a -test on a population mean is:
where:
- = sample mean
- = hypothesized population mean (from )
- = population standard deviation
- = sample size
Critical values for the -test
Common critical -values are:
| Confidence Level | α | Two-Tail z | One-Tail z |
|---|---|---|---|
| 90% | 0.10 | ±1.645 | 1.282 |
| 95% | 0.05 | ±1.960 | 1.645 |
| 99% | 0.01 | ±2.576 | 2.326 |
The -distribution and the -test
The -distribution (also called Student’s t-distribution) was developed by William Sealy Gosset, who published under the pseudonym “Student” in 1908. This distribution is fundamental to statistical inference when working with small samples or when the population standard deviation is unknown.
The -distribution is similar to the standard normal distribution (“bell curve”) but has heavier tails, meaning it assigns more probability to extreme values. This accounts for the additional uncertainty introduced when estimating the population standard deviation from sample data.
Degrees of freedom
The shape of the -distribution depends on a parameter called degrees of freedom (df), which is typically equal to , where is the sample size. As the degrees of freedom increase, the -distribution approaches the standard normal distribution. For practical purposes, when df > 30, the t-distribution is nearly identical to the normal distribution.
The exceedance probability
The exceedance (i.e., the probability of being incorrect), , is equal to the total area under the tail(s) of the distribution beyond the critical value(s).
- For a one-tail test:
- For a two-tail test: is placed in each tail, so the total exceedance is
When to Use the -test
The t-test is used when:
- The population standard deviation σ is unknown, AND
- The sample size is small ( < 30)
The -test statistic
The test statistic for a t-test on a population mean is:
where:
- = sample mean
- = hypothesized population mean (from )
- = sample standard deviation
- = sample size
-test for comparing two means
When comparing the means of two independent samples (“1” and “2”), the t-test statistic is:
where:
- = sample mean for sample
- = hypothesized population mean for
- = sample standard deviation for
- = sample size for
Choosing between the -test and the -test
Use the following guidelines to select the appropriate test:
- Is σ known?
- Yes → Use z-test
- No → Continue to step 2
- Is n ≥ 30?
- Yes → Use z-test (with s approximating σ)
- No → Use t-test
Summary comparison
| Feature | Z-Test | T-Test |
|---|---|---|
| Population σ | Known | Unknown |
| Sample size | Any (typically large) | Any (typically small) |
| Distribution | Standard normal | Student’s t |
| Critical values | Fixed for given α | Depend on df |
| As n → ∞ | — | Approaches z-test |
Conclusion
Hypothesis testing provides a rigorous framework for making decisions based on sample data. The key concepts covered in this section include:
- Confidence levels quantify our certainty in statistical conclusions
- Confidence intervals provide ranges likely to contain population parameters
- Hypothesis tests follow a systematic six-step procedure
- The -test is used when is known or is large (more than 30)
- The -test is used when is unknown and is small (fewer than 30)
- Type I and Type II errors represent the two ways a hypothesis test can lead to incorrect conclusions
Understanding when to apply each test and how to interpret the results is essential for engineers and scientists who must make data-driven decisions under uncertainty.