{ } Raw JSON

bundles / scipy 1.17.1 / scipy / stats / _continuous_distns / kstwo_gen

class

scipy.stats._continuous_distns:kstwo_gen

source: /scipy/stats/_continuous_distns.py :197

Signature

class   kstwo_gen ( momtype = 1 a = None b = None xtol = 1e-14 badvalue = None name = None longname = None shapes = None seed = None )

Members

Summary

Kolmogorov-Smirnov two-sided test statistic distribution.

Extended Summary

This is the distribution of the two-sided Kolmogorov-Smirnov (KS) statistic for a finite sample size n >= 1 (the shape parameter).

%(before_notes)s

Notes

is given by

where is a (continuous) CDF and is an empirical CDF. kstwo describes the distribution under the null hypothesis of the KS test that the empirical CDF corresponds to i.i.d. random variates with CDF .

%(after_notes)s

Examples

import numpy as np
from scipy.stats import kstwo
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 1)
Display the probability density function (``pdf``):
n = 10
x = np.linspace(kstwo.ppf(0.01, n),
                kstwo.ppf(0.99, n), 100)
ax.plot(x, kstwo.pdf(x, n),
        'r-', lw=5, alpha=0.6, label='kstwo pdf')
Alternatively, the distribution object can be called (as a function) to fix the shape, location and scale parameters. This returns a "frozen" RV object holding the given parameters fixed. Freeze the distribution and display the frozen ``pdf``:
rv = kstwo(n)
ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')
ax.legend(loc='best', frameon=False)
plt.show()
fig-f5fd6090b28247e4.png
Check accuracy of ``cdf`` and ``ppf``:
vals = kstwo.ppf([0.001, 0.5, 0.999], n)
np.allclose([0.001, 0.5, 0.999], kstwo.cdf(vals, n))

See also

ksone
kstest
kstwobign

Aliases

  • scipy.stats._continuous_distns.kstwo_gen