Welcome back to the AI Bayeslab Statistics series.
Building on our earlier conversation, where we introduced the Chi-Squared and F-Distributions related to sample variance and their potential business applications, today we will delve into a specific application referenced in the last article. Specifically, we will explore:
Parameter Estimation and Hypothesis Testing for Population Variance
This involves the statistic constructed from the ratio of sample variance s² to population variance σ².
1.Problem Statement for Today
We aim to address the following:
Case description: A factory historically produces bolts with a length variance of σ² = 0.04 mm². A new sample of 30 bolts yields a sample variance of s² = 0.0729 mm². Can we conclude that the production process has become less consistent? (One-tailed χ² test: H₀: σ² ≤ 0.04 vs. H₁: σ² > 0.04)
Constructing the Test Statistic: Given a sample from a normally distributed population, we use: \frac{(n-1)S^2}{\sigma^2} \sim \chi^2(n-1)
To perform hypothesis testing or confidence interval estimation for σ².
Business Context Example: Suppose a manufacturing process claims that the variance of product
Dimensions should not exceedσ_0^2 =0.04. We collect a sample, compute s², and test:
H₀: \sigma^2 \leq 0.04 \quad \text{(Quality is acceptable)}
H₁:\sigma^2 > 0.04 \quad \text{(Quality has deteriorated)}
Decision Rule:
If the test statistic \frac{(n-1)S^2}{\sigma_0^2} falls in the rejection region (e.g., > \chi^2_{\alpha, n-1} , we rejectH_0and conclude that quality control needs improvement.
Otherwise, we fail to rejectH_0 .
4.Visualization: Plotting the chi-square distribution with:
Critical value\chi^2_{\alpha, n-1},
Observed test statistic (marked in red).
2.Related formula illustration:
(1) Sample Variance S² and Population Variance σ² Ratio Statistic
The ratio of the sample variance S² to the population variance σ², scaled by degrees of freedom n−1, follows a chi-squared distribution with n−1 degrees of freedom:
\frac{(n-1)S^2}{\sigma^2} \sim \chi^2(n-1)
Where:
S² is the sample variance,
σ² is the population variance,
n is the sample size,
χ^2_{(n−1)}denotes the chi-squared distribution with n−1 degrees of freedom.
\frac{(n-1)S^2}{\sigma^2} \sim \chi^2(n-1)
(2) Confidence Interval for /\sigma^2
For a confidence level of 1- α, we can construct a confidence interval for σ². Let:
\chi^2_{\alpha/2, n-1}be the lower α/2-quantile of χ^2_{(n−1)}
\chi^2_{1-\alpha/2, n-1}be the upper α/2-quantile of χ^2_(n−1).
Then, the probability statement is:
P\left\{ \chi^2_{1-\alpha/2, n-1} \leq \frac{(n-1)S^2}{\sigma^2} \leq \chi^2_{\alpha/2, n-1} \right\} = 1 - \alpha
Rearranging the inequality gives the 1−α1−α confidence interval for \sigma^2:
P\left\{ \frac{(n-1)S^2}{\chi^2_{\alpha/2, n-1}} \leq \sigma^2 \leq \frac{(n-1)S^2}{\chi^2_{1-\alpha/2, n-1}} \right\} = 1 - \alpha
Thus, the confidence interval for \sigma^2is:
\left[ \frac{(n-1)S^2}{\chi^2_{\alpha/2, n-1}}, \frac{(n-1)S^2}{\chi^2_{1-\alpha/2, n-1}} \right]
3.Steps with AI Statistical analysis
We will now:
Implement this in Python (using
scipy.stats
for critical values andmatplotlib
for visualization).Interpret the results in the business context (e.g., recommending process adjustments if H₀ is rejected).
But all the code will be written by the online AI analysis tool, Bayeslab's AI block
These formulas hold under the assumption of a normally distributed population and apply to variance estimation and hypothesis testing problems. Now that we understand the statistical logic and formulas above, let’s use Bayeslab's AI Block feature and leverage an AI Agent to directly generate Python code to solve the initial business problem we posed.
Step 1: Compute Sample Variance, Test Statistic, and Critical Values
First, based on the given prompts, we derive the required sample variance, test statistic, and critical values. For clarity, we also instruct the LLM (AI Agent) to output the confidence interval along with the corresponding acceptance region and rejection region.

According to the data provided by the AI Agent:
Sample Variance: 0.0729 mm²
Chi-Squared Statistic: 52.8475
Critical Value: 42.5570
Confidence Interval for Variance: (0.0497, 0.1194)
Region of Acceptance: (-∞, 42.5570]
Region of Rejection: (42.5570, ∞)
Conclusion: Reject H₀: The production process has become less consistent.
We ultimately reject the initial null hypothesis. Our original null hypothesis was:
H₀: σ²≤0.04
This means that the production line's quality control has indeed deteriorated. Therefore, in practice, we should strengthen process management, improve product quality, and reduce the defect rate.
Step 2: Visualization for Better Understanding
To better interpret the numerical results, we can also ask the AI Agent to generate a corresponding visualization. As seen in the graph, the red dot (observed test statistic) falls in the rejection region, specifically to the right of the critical value.

Key Formulas (Recap):
Test Statistic:$$\chi^2_{\text{test}} = \frac{(n-1)S^2}{\sigma_0^2}$$
Rejection Region (Upper-Tailed Test):$$\chi^2_{\text{test}} > \chi^2_{\alpha, n-1}$$
Confidence Interval for σ² (as previously derived).
Stay tuned, subscribe to Bayeslab, and let everyone master the wisdom of statistics at a low cost with the AI Agent Online tool.