Following the previous template on the overall framework of Hypothesis Testing, today we will use a specific case to complete a parametric hypothesis test on the population mean.
We will use a real-world example and Bayeslab’s AI visualization tools to help you better and more deeply understand statistical analysis methods.
Throughout this process, we will use the Bayeslab online AI analysis tool. With the help of AI Agent’s visualization capabilities, we can obtain Python analytical code tailored by the AI Agent with just simple prompts. This approach enables us to efficiently perform Python data visualization and routine business analysis.
The outcome includes not only a set of visualized images but also Python source code, data analysis files, and even assists individuals with no statistical or Python coding background to complete professional data analysis.
OK, let’s get started.
1.Confidence Intervals: Normal Distribution Sampling
We know that the population X follows a normal distribution. If we take a random sample (X₁, X₂, …, Xₙ) from this population using simple random sampling, the sample mean X̅ also follows a normal distribution, and

So, assuming that H₀: μ = μ₀ holds true, if the significance level α is set at 0.05, due to the symmetry of the normal distribution, we know that P{|Z| ≥ 1.96} = 0.05, meaning the probability that the absolute value of Z exceeds 1.96 is 0.05. In other words, the probability that X̅ falls outside the region (μ ± 1.96σ/√n) is 0.05. If we now calculate that X̅ falls outside the region (μ ± 1.96σ/√n) (the rejection region), we reject the null hypothesis and accept the alternative hypothesis.
By substituting the significance level α into the general form P{|Z| ≥ Zₐ/₂} = α, we illustrate that as long as the probability that the absolute value of Z exceeds Zₐ/₂ is α, the probability that X̅ falls outside the region (μ ± Zₐ/₂ · σ/√n) is α. If it falls into the corresponding region, we reject the null hypothesis.
Previously, we mentioned that when performing hypothesis testing, we need to consider whether to use a one-tailed or two-tailed test. The above test is based on a two-tailed test. For information on when to use one-tailed or two-tailed tests, please refer to our other template introduction 2.3 Probabilities and Significant Level_Inferential Statistics (2).
Now let’s look at a specific example together. Let’s work through it step by step.
2. Example of a parametric test for Sample vs Population
Case Introduction: Hypothesis Testing for the Population Mean (σ² Known)
▶︎ We now have a simple random sample with a sample size of 25, and the sample mean is 102.68.
▶︎ The data reflects the French test scores of 25 students this year.
▶︎ It is assumed that the French test scores follow a normal distribution. X~N(μ,σ²)
▶︎ Historically, the population mean (μ) = 100 and the population variance (σ²) = 5.

(Raw data preview)

(AI Block by Bayeslab)
Now, we need you to perform hypothesis testing at a 5% significance level to determine if there is a significant difference between this year’s French test scores and past scores.
Step1. State the Hypotheses:
Null Hypothesis (H₀):
Typically represents no significant difference or effect. For example,
H₀: μ = 100 (the population mean equals 100).
Alternative Hypothesis (H₁):
Indicates a significant difference or effect.
For example, H₁: μ ≠ 100 (the population mean does not equal 100).
Step2. Choose the Significance Level and Appropriate Test
Determine the significance level (commonly α = 0.05).
Select the appropriate test statistic (e.g., z-test or t-test).
Given that the population variance σ² is known and follows a normal distribution X~N(μ,σ²), we naturally choose the Z-test.
Note:
The sample size here is 25. If there are fewer than 30 samples and we are not sure if the population follows a normal distribution, we need to choose the t-test.
However, if the sample size exceeds 30, we can approximately assume it follows a normal distribution and still use the Z-test.
Z-Test Formula:

Where:
▪︎ X̅: is the sample mean
▪︎ μ: is the population mean
▪︎ σ: is the population standard deviation
▪︎ n: is the sample size
t-Test Formula:

Where:
▪︎ X̅: is the sample mean
▪︎ μ: is the population mean
▪︎ s: is the sample standard deviation
▪︎ n: is the sample size
Step3. Calculate the Test Statistic
Let’s use the following Z-test formula for the calculations. However, here we are using the AI agent built into Bayeslab.
We will directly tell the AI to use the prompt method to obtain our calculation results and then use step four to have the AI directly determine whether to accept or reject the null hypothesis, as well as provide the final business analysis results.

Step4. Make a Decision
Determine the critical value or p-value.
Compare the calculated test statistic to the critical value, or compare the p-value to the significance level α.
If the test statistic exceeds the critical value or the p-value is less than the significance level, reject the null hypothesis H₀;
otherwise, fail to reject the null hypothesis H₀.

Here is a simple process for hypothesis testing of the overall mean. Thank you for reading. We will explain other scenarios later, such as:
(1) When the population variance σ² is known, for two normal populations or non-normal populations with large samples (n≥30);
(2) When the population variance σ² is unknown and variances are homogeneous, for two normal populations or non-normal populations with large samples (n≥30);
(3) When the population variance σ² is unknown and variances are heterogeneous, for two normal populations or non-normal populations with large samples (n≥30);
Additionally, related samples where there is a one-to-one correspondence between samples, meaning the samples are dependent on each other.
Furthermore, we will introduce other concepts of hypothesis testing such as:
Statistical Power
Power Function
Effect Size
ω² (Omega Squared)
α error (Type I)
We aim to help you master professional statistics and data analysis using the simplest approach, combining Bayeslab with specific business cases.
👻 Stay tuned.
About Bayeslab
Bayeslab: Website
The AI First Data Workbench
X: @BayeslabAI
Documents: https://bayeslab.gitbook.io/docs
Blogs:https://bayeslab.ai/blog
