Teach yourself statistics
This lesson explains how to conduct a hypothesis test of a mean, when the following conditions are met:
Generally, the sampling distribution will be approximately normally distributed if any of the following conditions apply.
This approach consists of four steps: (1) state the hypotheses, (2) formulate an analysis plan, (3) analyze sample data, and (4) interpret results.
Every hypothesis test requires the analyst to state a null hypothesis and an alternative hypothesis . The hypotheses are stated in such a way that they are mutually exclusive. That is, if one is true, the other must be false; and vice versa.
The table below shows three sets of hypotheses. Each makes a statement about how the population mean μ is related to a specified value M . (In the table, the symbol ≠ means " not equal to ".)
Set | Null hypothesis | Alternative hypothesis | Number of tails |
---|---|---|---|
1 | μ = M | μ ≠ M | 2 |
2 | μ M | μ < M | 1 |
3 | μ M | μ > M | 1 |
The first set of hypotheses (Set 1) is an example of a two-tailed test , since an extreme value on either side of the sampling distribution would cause a researcher to reject the null hypothesis. The other two sets of hypotheses (Sets 2 and 3) are one-tailed tests , since an extreme value on only one side of the sampling distribution would cause a researcher to reject the null hypothesis.
The analysis plan describes how to use sample data to accept or reject the null hypothesis. It should specify the following elements.
Using sample data, conduct a one-sample t-test. This involves finding the standard error, degrees of freedom, test statistic, and the P-value associated with the test statistic.
SE = s * sqrt{ ( 1/n ) * [ ( N - n ) / ( N - 1 ) ] }
SE = s / sqrt( n )
t = ( x - μ) / SE
As you probably noticed, the process of hypothesis testing can be complex. When you need to test a hypothesis about a mean score, consider using the Sample Size Calculator. The calculator is fairly easy to use, and it is free. You can find the Sample Size Calculator in Stat Trek's main menu under the Stat Tools tab. Or you can tap the button below.
If the sample findings are unlikely, given the null hypothesis, the researcher rejects the null hypothesis. Typically, this involves comparing the P-value to the significance level , and rejecting the null hypothesis when the P-value is less than the significance level.
In this section, two sample problems illustrate how to conduct a hypothesis test of a mean score. The first problem involves a two-tailed test; the second problem, a one-tailed test.
Problem 1: Two-Tailed Test
An inventor has developed a new, energy-efficient lawn mower engine. He claims that the engine will run continuously for 5 hours (300 minutes) on a single gallon of regular gasoline. From his stock of 2000 engines, the inventor selects a simple random sample of 50 engines for testing. The engines run for an average of 295 minutes, with a standard deviation of 20 minutes. Test the null hypothesis that the mean run time is 300 minutes against the alternative hypothesis that the mean run time is not 300 minutes. Use a 0.05 level of significance. (Assume that run times for the population of engines are normally distributed.)
Solution: The solution to this problem takes four steps: (1) state the hypotheses, (2) formulate an analysis plan, (3) analyze sample data, and (4) interpret results. We work through those steps below:
Null hypothesis: μ = 300
Alternative hypothesis: μ ≠ 300
SE = s / sqrt(n) = 20 / sqrt(50) = 20/7.07 = 2.83
DF = n - 1 = 50 - 1 = 49
t = ( x - μ) / SE = (295 - 300)/2.83 = -1.77
where s is the standard deviation of the sample, x is the sample mean, μ is the hypothesized population mean, and n is the sample size.
Since we have a two-tailed test , the P-value is the probability that the t statistic having 49 degrees of freedom is less than -1.77 or greater than 1.77. We use the t Distribution Calculator to find P(t < -1.77) is about 0.04.
Note: If you use this approach on an exam, you may also want to mention why this approach is appropriate. Specifically, the approach is appropriate because the sampling method was simple random sampling, the population was normally distributed, and the sample size was small relative to the population size (less than 5%).
Problem 2: One-Tailed Test
Bon Air Elementary School has 1000 students. The principal of the school thinks that the average IQ of students at Bon Air is at least 110. To prove her point, she administers an IQ test to 20 randomly selected students. Among the sampled students, the average IQ is 108 with a standard deviation of 10. Based on these results, should the principal accept or reject her original hypothesis? Assume a significance level of 0.01. (Assume that test scores in the population of engines are normally distributed.)
Null hypothesis: μ >= 110
Alternative hypothesis: μ < 110
SE = s / sqrt(n) = 10 / sqrt(20) = 10/4.472 = 2.236
DF = n - 1 = 20 - 1 = 19
t = ( x - μ) / SE = (108 - 110)/2.236 = -0.894
Here is the logic of the analysis: Given the alternative hypothesis (μ < 110), we want to know whether the observed sample mean is small enough to cause us to reject the null hypothesis.
The observed sample mean produced a t statistic test statistic of -0.894. We use the t Distribution Calculator to find P(t < -0.894) is about 0.19.
by Marco Taboga , PhD
This lecture explains how to conduct hypothesis tests about the mean of a normal distribution.
We tackle two different cases:
when we know the variance of the distribution, then we use a z-statistic to conduct the test;
when the variance is unknown, then we use the t-statistic.
In each case we derive the power and the size of the test.
We conclude with two solved exercises on size and power.
Table of contents
The null hypothesis, the test statistic, the critical region, the decision, the power function, the size of the test, how to choose the critical value, unknown variance: the t-test, how to choose the critical values, solved exercises.
The assumptions are the same we made in the lecture on confidence intervals for the mean .
A test of hypothesis based on it is called z-test .
Otherwise, it is not rejected.
We explain how to do this in the page on critical values .
This case is similar to the previous one. The only difference is that we now relax the assumption that the variance of the distribution is known.
The test of hypothesis based on it is called t-test .
Otherwise, we do not reject it.
The page on critical values explains how this equation is solved.
Below you can find some exercises with explained solutions.
Suppose that a statistician observes 100 independent realizations of a normal random variable.
The mean and the variance of the random variable, which the statistician does not know, are equal to 1 and 4 respectively.
Find the probability that the statistician will reject the null hypothesis that the mean is equal to zero if:
she runs a t-test based on the 100 observed realizations;
A statistician observes 100 independent realizations of a normal random variable.
She performs a t-test of the null hypothesis that the mean of the variable is equal to zero.
Please cite as:
Taboga, Marco (2021). "Hypothesis tests about the mean", Lectures on probability theory and mathematical statistics. Kindle Direct Publishing. Online appendix. https://www.statlect.com/fundamentals-of-statistics/hypothesis-testing-mean.
Most of the learning materials found on this website are now available in a traditional textbook format.
Descriptive statistics, inferential statistics, stat reference, statistics - hypothesis testing a mean.
A population mean is an average of value a population.
Hypothesis tests are used to check a claim about the size of that population mean.
The following steps are used for a hypothesis test:
For example:
And we want to check the claim:
"The average age of Nobel Prize winners when they received the prize is more than 55"
By taking a sample of 30 randomly selected Nobel Prize winners we could find that:
The mean age in the sample (\(\bar{x}\)) is 62.1
The standard deviation of age in the sample (\(s\)) is 13.46
From this sample data we check the claim with the steps below.
The conditions for calculating a confidence interval for a proportion are:
A moderately large sample size, like 30, is typically large enough.
In the example, the sample size was 30 and it was randomly selected, so the conditions are fulfilled.
Note: Checking if the data is normally distributed can be done with specialized statistical tests.
We need to define a null hypothesis (\(H_{0}\)) and an alternative hypothesis (\(H_{1}\)) based on the claim we are checking.
The claim was:
In this case, the parameter is the mean age of Nobel Prize winners when they received the prize (\(\mu\)).
The null and alternative hypothesis are then:
Null hypothesis : The average age was 55.
Alternative hypothesis : The average age was more than 55.
Which can be expressed with symbols as:
\(H_{0}\): \(\mu = 55 \)
\(H_{1}\): \(\mu > 55 \)
This is a ' right tailed' test, because the alternative hypothesis claims that the proportion is more than in the null hypothesis.
If the data supports the alternative hypothesis, we reject the null hypothesis and accept the alternative hypothesis.
Advertisement
The significance level (\(\alpha\)) is the uncertainty we accept when rejecting the null hypothesis in a hypothesis test.
The significance level is a percentage probability of accidentally making the wrong conclusion.
Typical significance levels are:
A lower significance level means that the evidence in the data needs to be stronger to reject the null hypothesis.
There is no "correct" significance level - it only states the uncertainty of the conclusion.
Note: A 5% significance level means that when we reject a null hypothesis:
We expect to reject a true null hypothesis 5 out of 100 times.
The test statistic is used to decide the outcome of the hypothesis test.
The test statistic is a standardized value calculated from the sample.
The formula for the test statistic (TS) of a population mean is:
\(\displaystyle \frac{\bar{x} - \mu}{s} \cdot \sqrt{n} \)
\(\bar{x}-\mu\) is the difference between the sample mean (\(\bar{x}\)) and the claimed population mean (\(\mu\)).
\(s\) is the sample standard deviation .
\(n\) is the sample size.
In our example:
The claimed (\(H_{0}\)) population mean (\(\mu\)) was \( 55 \)
The sample mean (\(\bar{x}\)) was \(62.1\)
The sample standard deviation (\(s\)) was \(13.46\)
The sample size (\(n\)) was \(30\)
So the test statistic (TS) is then:
\(\displaystyle \frac{62.1-55}{13.46} \cdot \sqrt{30} = \frac{7.1}{13.46} \cdot \sqrt{30} \approx 0.528 \cdot 5.477 = \underline{2.889}\)
You can also calculate the test statistic using programming language functions:
With Python use the scipy and math libraries to calculate the test statistic.
With R use built-in math and statistics functions to calculate the test statistic.
There are two main approaches for making the conclusion of a hypothesis test:
Note: The two approaches are only different in how they present the conclusion.
For the critical value approach we need to find the critical value (CV) of the significance level (\(\alpha\)).
For a population mean test, the critical value (CV) is a T-value from a student's t-distribution .
This critical T-value (CV) defines the rejection region for the test.
The rejection region is an area of probability in the tails of the standard normal distribution.
Because the claim is that the population mean is more than 55, the rejection region is in the right tail:
The student's t-distribution is adjusted for the uncertainty from smaller samples.
This adjustment is called degrees of freedom (df), which is the sample size \((n) - 1\)
In this case the degrees of freedom (df) is: \(30 - 1 = \underline{29} \)
Choosing a significance level (\(\alpha\)) of 0.01, or 1%, we can find the critical T-value from a T-table , or with a programming language function:
With Python use the Scipy Stats library t.ppf() function find the T-Value for an \(\alpha\) = 0.01 at 29 degrees of freedom (df).
With R use the built-in qt() function to find the t-value for an \(\alpha\) = 0.01 at 29 degrees of freedom (df).
Using either method we can find that the critical T-Value is \(\approx \underline{2.462}\)
For a right tailed test we need to check if the test statistic (TS) is bigger than the critical value (CV).
If the test statistic is bigger than the critical value, the test statistic is in the rejection region .
When the test statistic is in the rejection region, we reject the null hypothesis (\(H_{0}\)).
Here, the test statistic (TS) was \(\approx \underline{2.889}\) and the critical value was \(\approx \underline{2.462}\)
Here is an illustration of this test in a graph:
Since the test statistic was bigger than the critical value we reject the null hypothesis.
This means that the sample data supports the alternative hypothesis.
And we can summarize the conclusion stating:
The sample data supports the claim that "The average age of Nobel Prize winners when they received the prize is more than 55" at a 1% significance level .
For the P-value approach we need to find the P-value of the test statistic (TS).
If the P-value is smaller than the significance level (\(\alpha\)), we reject the null hypothesis (\(H_{0}\)).
The test statistic was found to be \( \approx \underline{2.889} \)
For a population proportion test, the test statistic is a T-Value from a student's t-distribution .
Because this is a right tailed test, we need to find the P-value of a t-value bigger than 2.889.
The student's t-distribution is adjusted according to degrees of freedom (df), which is the sample size \((30) - 1 = \underline{29}\)
We can find the P-value using a T-table , or with a programming language function:
With Python use the Scipy Stats library t.cdf() function find the P-value of a T-value bigger than 2.889 at 29 degrees of freedom (df):
With R use the built-in pt() function find the P-value of a T-Value bigger than 2.889 at 29 degrees of freedom (df):
Using either method we can find that the P-value is \(\approx \underline{0.0036}\)
This tells us that the significance level (\(\alpha\)) would need to be bigger than 0.0036, or 0.36%, to reject the null hypothesis.
This P-value is smaller than any of the common significance levels (10%, 5%, 1%).
So the null hypothesis is rejected at all of these significance levels.
The sample data supports the claim that "The average age of Nobel Prize winners when they received the prize is more than 55" at a 10%, 5%, or 1% significance level .
Note: An outcome of an hypothesis test that rejects the null hypothesis with a p-value of 0.36% means:
For this p-value, we only expect to reject a true null hypothesis 36 out of 10000 times.
Many programming languages can calculate the P-value to decide outcome of a hypothesis test.
Using software and programming to calculate statistics is more common for bigger sets of data, as calculating manually becomes difficult.
The P-value calculated here will tell us the lowest possible significance level where the null-hypothesis can be rejected.
With Python use the scipy and math libraries to calculate the P-value for a right tailed hypothesis test for a mean.
Here, the sample size is 30, the sample mean is 62.1, the sample standard deviation is 13.46, and the test is for a mean bigger than 55.
With R use built-in math and statistics functions find the P-value for a right tailed hypothesis test for a mean.
This was an example of a right tailed test, where the alternative hypothesis claimed that parameter is bigger than the null hypothesis claim.
You can check out an equivalent step-by-step guide for other types here:
If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected]
If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected]
Top references, top examples, get certified.
IMAGES
VIDEO
COMMENTS
There are five steps in hypothesis testing when using the traditional method: Identify the claim and formulate the hypotheses. Compute the test statistic. Compute the critical value (s) and state the rejection rule (the rule by which you will reject the null hypothesis (H 0).
We consider three hypothesis testing problems. The first one is a test to decide between the following hypotheses: H0: μ = μ0, H1: μ ≠ μ0. In this case, the null hypothesis is a simple hypothesis and the alternative hypothesis is a two-sided hypothesis (i.e., it includes both μ <μ0 and μ> μ0).
How to conduct a hypothesis test for a mean value, using a one-sample t-test. The test procedure is illustrated with examples for one- and two-tailed tests.
In this “Hypothesis Test for a Population Mean,” we looked at the four steps of a hypothesis test as they relate to a claim about a population mean. Step 1: Determine the hypotheses. The hypotheses are claims about the population mean, µ.
The mean of the sample means will equal the population mean and the mean of the sample sums will equal \(n\) times the population mean. The standard deviation of the distribution of the sample means, \(\frac{\sigma}{\sqrt{n}}\), is called the standard error of the mean.
Six Steps for Conducting a One-Sample Mean Hypothesis Test. Steps 1-3. Let's apply the general steps for hypothesis testing to the specific case of testing a one-sample mean. Step 1: Set up the hypotheses and check conditions.
To learn how to apply the five-step test procedure for test of hypotheses concerning a population mean when the sample size is small.
To construct a test statistic, we use the sample mean. The test statistic, called z-statistic, is. A test of hypothesis based on it is called z-test. We prove below that has a normal distribution with zero mean and unit variance. The critical region is where . Thus, the critical values of the test are and .
With R use built-in math and statistics functions find the P-value for a right tailed hypothesis test for a mean. Here, the sample size is 30, the sample mean is 62.1, the sample standard deviation is 13.46, and the test is for a mean bigger than 55.
A one-sample t-test can use the sample data to determine whether the entire population of soda cans differs from the hypothesized value of 12 ounces. In this post, learn about the one-sample t-test, its hypotheses and assumptions, and how to interpret the results.