Stats ttestresult - CyrilB1531/lodestar GitHub Wiki
Development build. This page describes
main, not a released package. The latest published Lodestar.Stats is 0.4.0 — read its documentation.
Home › Stats › Hypothesis tests
TTestResult
A t-test's result: the statistic, the p-value and the degrees of freedom.
public sealed record TTestResult(double Statistic, double PValue, double Df)
Properties — Statistic is the t statistic. PValue is the p-value on the requested tail.
Df is the degrees of freedom: integral for Student and for the paired and one-sample tests,
fractional for Welch, whose Satterthwaite denominator is not a count of anything.
Example — a one-sample test's degrees of freedom: one less than the number of values
actually tested, sample.Length - 1 here since the default
NanPolicy.Propagate tests every value — one less than the filtered length
under NanPolicy.Omit instead.
using Lodestar.Stats;
double[] sample = [12.1, 9.4, 15.0, 11.2, 8.8, 13.9, 10.5];
TTestResult result = TTest.OneSample(sample, populationMean: 10.0);
double df = result.Df; // => 6
Remarks — Df is a double, not an int, because TTest.Independent
under Variance.Welch needs to report a fractional value; every other entry
point happens to land on a whole number, which is why this example's 6 prints with no decimal
point at all — it is still the same double field.
Alongside the three public properties, a TTestResult privately carries the estimate its test
compared and its standard error — internal, since scikit-learn-style callers only reach them
through ConfidenceInterval, which is where they surface.
Being a record, two results with the same statistic, p-value and degrees of freedom are equal.
Applies to — net10.0, netstandard2.0.
See also — TTest.Independent, TTest.Paired,
TTest.OneSample, TestResult, the
Python equivalence table.
Members
| Member | What it does |
|---|---|
TTestResult.ConfidenceInterval |
The confidence interval for the difference this test measured. |