Stats ksresult - 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.

HomeStatsHypothesis tests

KsResult

A two-sample Kolmogorov-Smirnov result.

public sealed record KsResult(double Statistic, double PValue, double StatisticLocation, int StatisticSign)

PropertiesStatistic is the supremum distance between the two empirical distributions. PValue is the p-value on the requested tail. StatisticLocation is the observed value at which that supremum is attained. StatisticSign is +1 when the first sample's empirical distribution exceeds the second's at that point, -1 when it falls below.

Example — two samples of the same size, shifted apart.

using Lodestar.Stats;

double[] left = [1.0, 2.0, 3.0, 4.0, 5.0];
double[] right = [3.0, 4.0, 5.0, 6.0, 7.0];

KsResult result = KolmogorovSmirnov.TwoSample(left, right);

double location = result.StatisticLocation;   // => 3
int sign = result.StatisticSign;              // => 1

RemarksStatisticLocation and StatisticSign are what TestResult cannot carry: a statistic and a p-value alone say how far apart two distributions are, not where. A sign of +1 here means left's empirical CDF is ahead of right's at location — every value in left has already been reached by 3.0, where right's has not — which is exactly what left's values sitting below right's means.

Being a record, two results with the same four fields are equal.

Applies to — net10.0, netstandard2.0.

See alsoKolmogorovSmirnov.TwoSample, TestResult, the Python equivalence table.