[5] Simultaneous Mean and Variance#
The functions in pysht.mean_variance test the mean and variance of
one or two univariate normal populations in one decision. A significant result
can reflect a mean departure, a variance departure, or both.
Question or calibration |
Function |
|---|---|
One population versus a specified mean and variance |
|
Pearson–Neyman beta approximation for two populations |
|
Perng–Littell combination of pooled-t and F tests |
|
Muirhead second-order likelihood-ratio approximation |
|
Zhang–Xu–Chen exact likelihood-ratio calibration |
|
Wilks asymptotic likelihood-ratio calibration |
|
All methods require independent normal observations and positive within-sample
variance. The scalar null variance for as_1samp is supplied with the
keyword variance; for example:
from pysht.mean_variance import as_1samp
result = as_1samp(x, popmean=2.0, variance=1.5)
print(result)
The result prints in the same compact style as an R htest object:
method, statistic, degrees of freedom where applicable, p-value, alternative,
and calibration. Pearson–Neyman beta shapes, Perng–Littell component
p-values, and Muirhead correction constants appear under immutable
diagnostics; they are calibration metadata, not parameter estimates.
For small samples, prefer zxc_2samp when exact likelihood-ratio
calibration is required. pn_2samp is a highly accurate moment
approximation in the validated normal scenarios. The chi-square calibrations
in as_1samp and lrt_2samp, and the finite Muirhead
expansion, are asymptotic approximations. The
validation ledger records the finite-sample
regimes that passed the release-size gate and the smaller regimes that did not.
Functions#
- pysht.mean_variance.as_1samp(x, *, popmean=0.0, variance=1.0)[source]#
Test one normal population mean and variance jointly.
This is the likelihood-ratio procedure discussed by Arnold and Shavelle (1998). It represents both
mvar1.1998ASandmvar1.LRTfrom SHT, whose statistics are algebraically identical.- Parameters:
- x
One-dimensional sample with positive sample variance.
- popmean
Population mean under the joint null hypothesis.
- variance
Positive population variance under the joint null hypothesis.
- Parameters:
x (ArrayLike)
popmean (float)
variance (float)
- Return type:
Notes
The chi-square calibration is asymptotic. Normality and independent observations are required.
- pysht.mean_variance.pn_2samp(x, y)[source]#
Perform the Pearson–Neyman two-sample normal-population test.
The null distribution of the likelihood ratio is approximated by a beta distribution whose parameters match its first two exact null moments. Small likelihood ratios contradict equality, so the p-value is the lower beta tail. This corrects the reversed tail in SHT 0.1.9.
- Parameters:
x (ArrayLike)
y (ArrayLike)
- Return type:
- pysht.mean_variance.pl_2samp(x, y)[source]#
Perform the Perng–Littell joint two-sample test.
Under independent normal samples and the joint null, the equal-variance pooled t statistic is independent of the sample-variance ratio. Fisher’s method therefore combines their two-sided p-values with a chi-square law having four degrees of freedom.
- Parameters:
x (ArrayLike)
y (ArrayLike)
- Return type:
- pysht.mean_variance.muirhead_2samp(x, y)[source]#
Perform Muirhead’s corrected likelihood-ratio approximation.
The second-order null approximation is evaluated in the upper tail. The finite expansion can leave the probability interval in extreme tails, so the reported approximation is truncated to
[0, 1].- Parameters:
x (ArrayLike)
y (ArrayLike)
- Return type:
- pysht.mean_variance.zxc_2samp(x, y)[source]#
Perform the exact Zhang–Xu–Chen two-sample normal test.
The likelihood ratio itself is reported. Its exact p-value is the lower tail because smaller ratios provide stronger evidence against equality. Computation stays in the log domain and uses the conditional-beta form of the null probability rather than exponentiating a two-dimensional quadrature integrand.
- Parameters:
x (ArrayLike)
y (ArrayLike)
- Return type:
- pysht.mean_variance.lrt_2samp(x, y)[source]#
Perform the asymptotic likelihood-ratio equality test.
The procedure tests equality of both parameters of two independent normal populations. Its statistic is
-2 log(Lambda)and its chi-square law is asymptotic.- Parameters:
x (ArrayLike)
y (ArrayLike)
- Return type: