[3] Tests for Variance#
pysht.variance provides classical one-, two-, and multi-sample procedures for
scalar population variances.
Question |
Function |
|---|---|
Is one variance equal to a reference value? |
|
Are two normal-population variances equal? |
|
Are several normal-population variances equal? |
|
Are several group spreads equal around their means? |
|
Are several group spreads equal around their medians? |
|
See the classical-variance validation ledger for assumptions, scale handling, and SciPy comparisons.
Functions#
Tests for one, two, and multiple population variances.
The chi-square, F, and Bartlett procedures are normal-theory tests. Levene’s test and its Brown–Forsythe median-centered variant are less sensitive to departures from normality, but their reported F distributions are still finite-sample approximations.
- pysht.variance.bartlett(*samples)[source]#
Test homogeneity of normal population variances across groups.
Bartlett’s statistic is especially sensitive to non-normality. Every sample must have positive sample variance; otherwise its logarithmic statistic is undefined and a
ValueErroris raised.References
Bartlett, M. S. (1937). Properties of sufficiency and statistical tests. Proceedings of the Royal Society A, 160, 268–282.
- Parameters:
samples (ArrayLike)
- Return type:
- pysht.variance.brown_forsythe(*samples)[source]#
Run the Brown–Forsythe median-centered test for equal variances.
References
Brown, M. B. and Forsythe, A. B. (1974). Robust tests for the equality of variances. Journal of the American Statistical Association, 69, 364–367.
- Parameters:
samples (ArrayLike)
- Return type:
- pysht.variance.chisquare_1samp(x, *, variance=1.0, alternative='two-sided', confidence_level=0.95)[source]#
Test one normal population variance against a positive value.
- Parameters:
- x
One-dimensional sample containing at least two finite real values.
- variance
Positive variance under the null hypothesis.
- alternative
"two-sided","less", or"greater".- confidence_level
Confidence coefficient for the interval obtained by inverting the chi-square pivot.
- Parameters:
x (ArrayLike)
variance (float)
alternative (str)
confidence_level (float)
- Return type:
Notes
Exact chi-square calibration requires independent normal observations. A constant sample is handled as the boundary statistic zero rather than as an arithmetic error.
References
Snedecor, G. W. and Cochran, W. G. (1996). Statistical Methods, 8th ed.
- pysht.variance.f_2samp(x, y, *, alternative='two-sided', confidence_level=0.95)[source]#
Test equality of two normal population variances with an F ratio.
The statistic is the unbiased sample variance of
xdivided by that ofy. Both sample variances must be strictly positive; constant samples are rejected explicitly because the ratio and its confidence interval are then degenerate.References
Snedecor, G. W. and Cochran, W. G. (1996). Statistical Methods, 8th ed.
- Parameters:
x (ArrayLike)
y (ArrayLike)
alternative (str)
confidence_level (float)
- Return type: