One-sample, two-sample (pooled and Welch) and paired t tests, the z test, and chi-square and F tests of variances, with p-values, critical values and confidence intervals.
instant: A closed-form calculation; a hosted run may take up to 2 seconds.
Formula
Where
The t statistic statistic
Sample mean mean
The mean under the null hypothesis hypothesized_mean
Sample standard deviation sd
Sample size n
Degrees of freedom degrees_of_freedom
Mean of the first sample mean1
Mean of the second sample mean2
The difference in means under the null hypothesis hypothesized_difference
Pooled standard deviation of the two samples
Size of the first sample n1
Size of the second sample n2
Standard deviation of the first sample sd1
Standard deviation of the second sample sd2
The z statistic statistic
The population's known standard deviation sigma
The chi-square statistic statistic
The standard deviation under the null hypothesis hypothesized_sd
The F statistic statistic
Each symbol's field is named beside it; the inputs and outputs, with their units and bounds, are under Variables, and the citations give each formula's source.
Variables
Rates, returns and yields are decimals: 0.05 is five percent. Bounds in brackets include their end; in parentheses they exclude it.
Inputs
One-sample t test of a mean (one_sample_t): 7 inputs
F test of the ratio of two variances (f_variances): 7 inputs
Inputs of the calculation f_variances
Name
Unit
Bounds
Description
Alternativealternativetext
text
The alternative hypothesis
Alphaalphaprobability · [0.0001, 0.5]
probability
[0.0001, 0.5]
Significance level
Calculationcalculationtext
text
F test of the ratio of two variances
N1n1count · [2, 1e+06]
count
[2, 1e+06]
First sample size
Sd1sd1ratio · [0.0001, 10000]
ratio
[0.0001, 10000]
First sample standard deviation (n - 1)
N2n2count · [2, 1e+06]
count
[2, 1e+06]
Second sample size
Sd2sd2ratio · [0.0001, 10000]
ratio
[0.0001, 10000]
Second sample standard deviation (n - 1)
Outputs
One-sample t test of a mean (one_sample_t): 10 outputs
Outputs of the calculation one_sample_t
Name
Unit
Bounds
Description
Statisticstatisticratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
The test statistic
P valuep_valueprobability · [0, 1]
probability
[0, 1]
p-value for the chosen alternative
Critical valuescritical_valuesratio (array) · length min 1, max 2; each [-1e+30, 1e+30]
ratio (array)
length min 1, max 2; each [-1e+30, 1e+30]
Bounds of the rejection region: lower and upper for a two-sided test, the one bound for a one-sided test
Rejectrejectflag
flag
Whether the null hypothesis is rejected at alpha
Estimateestimateratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Point estimate of the quantity tested
Ci lowerci_lowerratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Lower end of the two-sided 1 - alpha confidence interval
Ci upperci_upperratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Upper end of the two-sided 1 - alpha confidence interval
Standard errorstandard_errorratio · [0, 100000]
ratio
[0, 100000]
Standard error of the estimate
Calculationcalculationtext
text
One-sample t test of a mean
Degrees of freedomdegrees_of_freedomratio · [0, 2e+06]
ratio
[0, 2e+06]
n - 1
Two-sample t test of a difference in means (two_sample_t): 10 outputs
Outputs of the calculation two_sample_t
Name
Unit
Bounds
Description
Statisticstatisticratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
The test statistic
P valuep_valueprobability · [0, 1]
probability
[0, 1]
p-value for the chosen alternative
Critical valuescritical_valuesratio (array) · length min 1, max 2; each [-1e+30, 1e+30]
ratio (array)
length min 1, max 2; each [-1e+30, 1e+30]
Bounds of the rejection region: lower and upper for a two-sided test, the one bound for a one-sided test
Rejectrejectflag
flag
Whether the null hypothesis is rejected at alpha
Estimateestimateratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Point estimate of the quantity tested
Ci lowerci_lowerratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Lower end of the two-sided 1 - alpha confidence interval
Ci upperci_upperratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Upper end of the two-sided 1 - alpha confidence interval
Standard errorstandard_errorratio · [0, 100000]
ratio
[0, 100000]
Standard error of the estimate
Calculationcalculationtext
text
Two-sample t test of a difference in means
Degrees of freedomdegrees_of_freedomratio · [0, 2e+06]
ratio
[0, 2e+06]
n1 + n2 - 2 when pooled; Welch-Satterthwaite otherwise
Paired t test of a mean difference (paired_t): 10 outputs
Outputs of the calculation paired_t
Name
Unit
Bounds
Description
Statisticstatisticratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
The test statistic
P valuep_valueprobability · [0, 1]
probability
[0, 1]
p-value for the chosen alternative
Critical valuescritical_valuesratio (array) · length min 1, max 2; each [-1e+30, 1e+30]
ratio (array)
length min 1, max 2; each [-1e+30, 1e+30]
Bounds of the rejection region: lower and upper for a two-sided test, the one bound for a one-sided test
Rejectrejectflag
flag
Whether the null hypothesis is rejected at alpha
Estimateestimateratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Point estimate of the quantity tested
Ci lowerci_lowerratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Lower end of the two-sided 1 - alpha confidence interval
Ci upperci_upperratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Upper end of the two-sided 1 - alpha confidence interval
Standard errorstandard_errorratio · [0, 100000]
ratio
[0, 100000]
Standard error of the estimate
Calculationcalculationtext
text
Paired t test of a mean difference
Degrees of freedomdegrees_of_freedomratio · [0, 2e+06]
ratio
[0, 2e+06]
n - 1
z test of a mean with known sigma (z_mean): 9 outputs
Outputs of the calculation z_mean
Name
Unit
Bounds
Description
Statisticstatisticratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
The test statistic
P valuep_valueprobability · [0, 1]
probability
[0, 1]
p-value for the chosen alternative
Critical valuescritical_valuesratio (array) · length min 1, max 2; each [-1e+30, 1e+30]
ratio (array)
length min 1, max 2; each [-1e+30, 1e+30]
Bounds of the rejection region: lower and upper for a two-sided test, the one bound for a one-sided test
Rejectrejectflag
flag
Whether the null hypothesis is rejected at alpha
Estimateestimateratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Point estimate of the quantity tested
Ci lowerci_lowerratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Lower end of the two-sided 1 - alpha confidence interval
Ci upperci_upperratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Upper end of the two-sided 1 - alpha confidence interval
Standard errorstandard_errorratio · [0, 100000]
ratio
[0, 100000]
Standard error of the estimate
Calculationcalculationtext
text
z test of a mean with known sigma
Chi-square test of a variance (chi_square_variance): 9 outputs
Outputs of the calculation chi_square_variance
Name
Unit
Bounds
Description
Statisticstatisticratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
The test statistic
P valuep_valueprobability · [0, 1]
probability
[0, 1]
p-value for the chosen alternative
Critical valuescritical_valuesratio (array) · length min 1, max 2; each [-1e+30, 1e+30]
ratio (array)
length min 1, max 2; each [-1e+30, 1e+30]
Bounds of the rejection region: lower and upper for a two-sided test, the one bound for a one-sided test
Rejectrejectflag
flag
Whether the null hypothesis is rejected at alpha
Estimateestimateratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Point estimate of the quantity tested
Ci lowerci_lowerratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Lower end of the two-sided 1 - alpha confidence interval
Ci upperci_upperratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Upper end of the two-sided 1 - alpha confidence interval
Calculationcalculationtext
text
Chi-square test of a variance
Degrees of freedomdegrees_of_freedomratio · [0, 2e+06]
ratio
[0, 2e+06]
n - 1
F test of the ratio of two variances (f_variances): 10 outputs
Outputs of the calculation f_variances
Name
Unit
Bounds
Description
Statisticstatisticratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
The test statistic
P valuep_valueprobability · [0, 1]
probability
[0, 1]
p-value for the chosen alternative
Critical valuescritical_valuesratio (array) · length min 1, max 2; each [-1e+30, 1e+30]
ratio (array)
length min 1, max 2; each [-1e+30, 1e+30]
Bounds of the rejection region: lower and upper for a two-sided test, the one bound for a one-sided test
Rejectrejectflag
flag
Whether the null hypothesis is rejected at alpha
Estimateestimateratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Point estimate of the quantity tested
Ci lowerci_lowerratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Lower end of the two-sided 1 - alpha confidence interval
Ci upperci_upperratio · [-1e+30, 1e+30]
ratio
[-1e+30, 1e+30]
Upper end of the two-sided 1 - alpha confidence interval
Calculationcalculationtext
text
F test of the ratio of two variances
Df numeratordf_numeratorratio · [0, 2e+06]
ratio
[0, 2e+06]
n1 - 1
Df denominatordf_denominatorratio · [0, 2e+06]
ratio
[0, 2e+06]
n2 - 1
Calculator
Run the model on your own inputs, starting from its example. Rates are decimals: 0.05 is five percent. The run goes to the pyeconomics API on this site: your values travel only in the request, and nothing is stored.
Samples are independent random samples; the t and z tests assume normal means, and the chi-square and F tests normal data.
Standard deviations are sample standard deviations with n - 1 in the denominator; sigma in the z test is known.
The confidence interval is always two-sided at 1 - alpha, whatever the alternative.
Limitations
The chi-square and F tests are sensitive to non-normal data; summary statistics cannot reveal it.
Welch's degrees of freedom are an approximation.
No correction is made for multiple comparisons.
Evidence
Status: standard. Textbook consensus, such as bond duration or the CAPM formula.
Every model declares one status: standard (textbook consensus), practitioner (a widely used convention), contested (under active debate), rejected (failed out of sample) or historical (a superseded methodology).
Syllabus
The 2027 CFA® Program's topic areas this model relates to, as factual tags. Each links to CFA Institute's page for its level; pyeconomics holds none of the curriculum's text.
Student (1908). The probable error of a mean. Biometrika, 6(1), 1-25. doi:10.1093/biomet/6.1.1 (The distribution of the mean over its estimated standard deviation)
Welch, B. L. (1947). The generalization of 'Student's' problem when several different population variances are involved. Biometrika, 34(1-2), 28-35. doi:10.1093/biomet/34.1-2.28 (The approximate degrees of freedom of the difference of two means)
Changelog
Version 1: First version.
Related models
Return toolkitHolding-period, arithmetic, geometric, harmonic, annualized, log and real returns.
Risk statisticsSample volatility and its annualization, semideviation, adjusted skewness and excess kurtosis, and maximum…
Monte Carlo simulationSeeded Monte Carlo of geometric Brownian motion, with antithetic variates, and the nonparametric bootstrap…
Time value of moneyPresent and future values of sums, annuities and perpetuities, the five-key solve, NPV, IRR, XNPV, XIRR and…