Calculator
Example Data Table
| Case | Test | n1 | n2 | D | Alpha | Use |
|---|---|---|---|---|---|---|
| Model fit | One sample | 50 | Not used | 0.180 | 0.05 | Compare sample with a theoretical CDF. |
| Group comparison | Two sample | 40 | 45 | 0.220 | 0.05 | Compare two empirical distributions. |
| Strict audit | One sample | 120 | Not used | 0.095 | 0.01 | Use a lower alpha level. |
Formula Used
For a one sample test, the effective sample size is n. For a two sample test, it is:
neff = n1n2 / (n1 + n2)
The corrected distance scale is:
λ = (√neff + 0.12 + 0.11 / √neff)D
Without correction, the calculator uses λ = √neffD.
The two sided p value approximation is:
p = 2 Σ (-1)j-1 e-2j²λ², for j from 1 upward.
The one sided approximation is:
p = e-2λ²
How to Use This Calculator
- Select one sample or two sample KS test.
- Choose the two sided or one sided p value option.
- Enter sample size one. Enter sample size two when needed.
- Enter the D statistic. You may also enter D plus and D minus.
- Set alpha, such as 0.05 or 0.01.
- Choose corrected or asymptotic scaling.
- Press the calculate button and read the result above the form.
- Download the CSV or PDF report for records.
Advanced KS Test P Value Guide
The Kolmogorov Smirnov test compares empirical distribution shapes. It does not only compare means. This makes it useful for skewed samples, simulation checks, model validation, and quality review. A small p value suggests the observed maximum gap is unusual under the chosen null model.
What The Statistic Measures
The statistic D is the largest vertical distance between cumulative curves. In a one sample test, the sample empirical curve is compared with a selected theoretical curve. In a two sample test, two empirical curves are compared. Larger D values give smaller p values, especially when sample sizes are high.
Why Corrections Matter
The asymptotic formula works well for many practical reports. Yet small samples can need a finite sample correction. This calculator applies a Stephens style adjustment when selected. The correction changes the lambda value before the probability series is evaluated. It gives a more cautious estimate for many ordinary cases.
Decision Reading
The p value is compared with alpha. Common alpha values are 0.10, 0.05, and 0.01. When p is lower than alpha, reject the null hypothesis. When p is higher, do not reject it. This wording matters. A high p value does not prove the distributions are identical. It only shows weak evidence against the null.
Good Inputs And Limits
Use the final KS statistic from your data table or software. Keep D between zero and one. Enter the actual sample size used after removing missing values. For two sample work, enter both sample sizes. If you have D plus and D minus values, enter them too. The calculator uses the largest relevant gap.
Reporting Results
A strong report should include D, sample size, p value, alpha, test type, and decision. Mention whether a correction was used. Avoid rounding too early. The export buttons help preserve the numeric output for later review. Always combine the result with study design, assumptions, and domain judgment.
Common Mistakes To Avoid
Do not treat the KS test as a normality test only. It can compare many continuous distributions. Avoid using rounded sample percentiles to compute D. Ties and discrete data can affect the p value. Document those limits before making decisions in final notes.
FAQs
What is a KS test p value?
It is the probability of seeing a KS statistic at least as large as the observed D value when the null hypothesis is true.
What does a small p value mean?
A small p value suggests the observed distribution gap is unlikely under the null model. It supports rejecting the null hypothesis at the chosen alpha.
Can I use this for a two sample KS test?
Yes. Select the two sample option, then enter both sample sizes and the observed D statistic from your empirical distributions.
What is the D statistic?
D is the largest vertical difference between cumulative distribution functions. It can come from one empirical curve or two empirical curves.
Should I use Stephens correction?
Use it for a practical finite sample adjustment. It often improves asymptotic p value estimates, especially when sample sizes are not very large.
Can this prove two distributions are equal?
No. A high p value only means there is not enough evidence against the null. It does not prove exact equality.
Why are D plus and D minus optional?
Some software reports directional gaps. If entered, the calculator uses the largest relevant gap as the KS statistic.
What should I include in a report?
Report the test type, D statistic, sample size, p value, alpha, correction method, and final decision.