<s>
In	O
statistics	O
,	O
the	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
test	I-General_Concept
(	O
K	B-General_Concept
–	I-General_Concept
S	I-General_Concept
test	I-General_Concept
or	O
KS	B-General_Concept
test	I-General_Concept
)	O
is	O
a	O
nonparametric	B-General_Concept
test	I-General_Concept
of	O
the	O
equality	O
of	O
continuous	O
(	O
or	O
discontinuous	O
,	O
see	O
Section	O
2.2	O
)	O
,	O
one-dimensional	O
probability	O
distributions	O
that	O
can	O
be	O
used	O
to	O
compare	O
a	O
sample	O
with	O
a	O
reference	O
probability	O
distribution	O
(	O
one-sample	O
K	B-General_Concept
–	I-General_Concept
S	I-General_Concept
test	I-General_Concept
)	O
,	O
or	O
to	O
compare	O
two	O
samples	O
(	O
two-sample	O
K	B-General_Concept
–	I-General_Concept
S	I-General_Concept
test	I-General_Concept
)	O
.	O
</s>
<s>
The	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
statistic	I-General_Concept
quantifies	O
a	O
distance	O
between	O
the	O
empirical	B-General_Concept
distribution	I-General_Concept
function	I-General_Concept
of	O
the	O
sample	O
and	O
the	O
cumulative	O
distribution	O
function	O
of	O
the	O
reference	O
distribution	O
,	O
or	O
between	O
the	O
empirical	B-General_Concept
distribution	I-General_Concept
functions	I-General_Concept
of	O
two	O
samples	O
.	O
</s>
<s>
The	O
null	B-General_Concept
distribution	I-General_Concept
of	O
this	O
statistic	O
is	O
calculated	O
under	O
the	O
null	B-General_Concept
hypothesis	I-General_Concept
that	O
the	O
sample	O
is	O
drawn	O
from	O
the	O
reference	O
distribution	O
(	O
in	O
the	O
one-sample	O
case	O
)	O
or	O
that	O
the	O
samples	O
are	O
drawn	O
from	O
the	O
same	O
distribution	O
(	O
in	O
the	O
two-sample	O
case	O
)	O
.	O
</s>
<s>
In	O
the	O
one-sample	O
case	O
,	O
the	O
distribution	O
considered	O
under	O
the	O
null	B-General_Concept
hypothesis	I-General_Concept
may	O
be	O
continuous	O
(	O
see	O
Section	O
2	O
)	O
,	O
purely	O
discrete	O
or	O
mixed	O
(	O
see	O
Section	O
2.2	O
)	O
.	O
</s>
<s>
In	O
the	O
two-sample	O
case	O
(	O
see	O
Section	O
3	O
)	O
,	O
the	O
distribution	O
considered	O
under	O
the	O
null	B-General_Concept
hypothesis	I-General_Concept
is	O
a	O
continuous	O
distribution	O
but	O
is	O
otherwise	O
unrestricted	O
.	O
</s>
<s>
However	O
,	O
the	O
two	B-General_Concept
sample	I-General_Concept
test	I-General_Concept
can	O
also	O
be	O
performed	O
under	O
more	O
general	O
conditions	O
that	O
allow	O
for	O
discontinuity	O
,	O
heterogeneity	O
and	O
dependence	O
across	O
samples	O
.	O
</s>
<s>
The	O
two-sample	O
K	B-General_Concept
–	I-General_Concept
S	I-General_Concept
test	I-General_Concept
is	O
one	O
of	O
the	O
most	O
useful	O
and	O
general	O
nonparametric	B-General_Concept
methods	O
for	O
comparing	O
two	O
samples	O
,	O
as	O
it	O
is	O
sensitive	O
to	O
differences	O
in	O
both	O
location	O
and	O
shape	O
of	O
the	O
empirical	B-General_Concept
cumulative	I-General_Concept
distribution	I-General_Concept
functions	I-General_Concept
of	O
the	O
two	O
samples	O
.	O
</s>
<s>
The	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
test	I-General_Concept
can	O
be	O
modified	O
to	O
serve	O
as	O
a	O
goodness	O
of	O
fit	O
test	O
.	O
</s>
<s>
This	O
is	O
equivalent	O
to	O
setting	O
the	O
mean	O
and	O
variance	O
of	O
the	O
reference	O
distribution	O
equal	O
to	O
the	O
sample	O
estimates	O
,	O
and	O
it	O
is	O
known	O
that	O
using	O
these	O
to	O
define	O
the	O
specific	O
reference	O
distribution	O
changes	O
the	O
null	B-General_Concept
distribution	I-General_Concept
of	O
the	O
test	O
statistic	O
(	O
see	O
Test	O
with	O
estimated	O
parameters	O
)	O
.	O
</s>
<s>
Various	O
studies	O
have	O
found	O
that	O
,	O
even	O
in	O
this	O
corrected	O
form	O
,	O
the	O
test	O
is	O
less	O
powerful	O
for	O
testing	O
normality	O
than	O
the	O
Shapiro	B-General_Concept
–	I-General_Concept
Wilk	I-General_Concept
test	I-General_Concept
or	O
Anderson	B-General_Concept
–	I-General_Concept
Darling	I-General_Concept
test	I-General_Concept
.	O
</s>
<s>
For	O
instance	O
the	O
Shapiro	B-General_Concept
–	I-General_Concept
Wilk	I-General_Concept
test	I-General_Concept
is	O
known	O
not	O
to	O
work	O
well	O
in	O
samples	O
with	O
many	O
identical	O
values	O
.	O
</s>
<s>
The	O
empirical	B-General_Concept
distribution	I-General_Concept
function	I-General_Concept
Fn	O
for	O
n	O
independent	O
and	O
identically	O
distributed	O
(	O
i.i.d.	O
)	O
</s>
<s>
Kolmogorov	O
strengthened	O
this	O
result	O
,	O
by	O
effectively	O
providing	O
the	O
rate	O
of	O
this	O
convergence	O
(	O
see	O
Kolmogorov	B-General_Concept
distribution	I-General_Concept
)	O
.	O
</s>
<s>
In	O
practice	O
,	O
the	O
statistic	O
requires	O
a	O
relatively	O
large	O
number	O
of	O
data	O
points	O
(	O
in	O
comparison	O
to	O
other	O
goodness	O
of	O
fit	O
criteria	O
such	O
as	O
the	O
Anderson	B-General_Concept
–	I-General_Concept
Darling	I-General_Concept
test	I-General_Concept
statistic	O
)	O
to	O
properly	O
reject	O
the	O
null	B-General_Concept
hypothesis	I-General_Concept
.	O
</s>
<s>
Both	O
the	O
form	O
of	O
the	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
test	I-General_Concept
statistic	O
and	O
its	O
asymptotic	O
distribution	O
under	O
the	O
null	B-General_Concept
hypothesis	I-General_Concept
were	O
published	O
by	O
Andrey	O
Kolmogorov	O
,	O
while	O
a	O
table	O
of	O
the	O
distribution	O
was	O
published	O
by	O
Nikolai	O
Smirnov	O
.	O
</s>
<s>
Under	O
null	B-General_Concept
hypothesis	I-General_Concept
that	O
the	O
sample	O
comes	O
from	O
the	O
hypothesized	O
distribution	O
F(x )	O
,	O
</s>
<s>
in	B-Algorithm
distribution	I-Algorithm
,	O
where	O
B(t )	O
is	O
the	O
Brownian	O
bridge	O
.	O
</s>
<s>
If	O
F	O
is	O
continuous	O
then	O
under	O
the	O
null	B-General_Concept
hypothesis	I-General_Concept
converges	O
to	O
the	O
Kolmogorov	B-General_Concept
distribution	I-General_Concept
,	O
which	O
does	O
not	O
depend	O
on	O
F	O
.	O
This	O
result	O
may	O
also	O
be	O
known	O
as	O
the	O
Kolmogorov	O
theorem	O
.	O
</s>
<s>
The	O
goodness-of-fit	O
test	O
or	O
the	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
test	I-General_Concept
can	O
be	O
constructed	O
by	O
using	O
the	O
critical	O
values	O
of	O
the	O
Kolmogorov	B-General_Concept
distribution	I-General_Concept
.	O
</s>
<s>
The	O
asymptotic	O
power	B-General_Concept
of	O
this	O
test	O
is	O
1	O
.	O
</s>
<s>
and	O
for	O
continuous	O
null	B-General_Concept
distributions	I-General_Concept
with	O
code	O
in	O
C	O
and	O
Java	B-Language
to	O
be	O
found	O
in	O
.	O
</s>
<s>
for	O
purely	O
discrete	O
,	O
mixed	O
or	O
continuous	O
null	B-General_Concept
distribution	I-General_Concept
implemented	O
in	O
the	O
KSgeneral	O
package	O
of	O
the	O
R	B-Language
project	I-Language
for	I-Language
statistical	I-Language
computing	I-Language
,	O
which	O
for	O
a	O
given	O
sample	O
also	O
computes	O
the	O
KS	B-General_Concept
test	I-General_Concept
statistic	O
and	O
its	O
p-value	O
.	O
</s>
<s>
In	O
such	O
cases	O
,	O
Monte	B-Algorithm
Carlo	I-Algorithm
or	O
other	O
methods	O
may	O
be	O
required	O
,	O
but	O
tables	O
have	O
been	O
prepared	O
for	O
some	O
cases	O
.	O
</s>
<s>
The	O
Lilliefors	B-General_Concept
test	I-General_Concept
represents	O
a	O
special	O
case	O
of	O
this	O
for	O
the	O
normal	O
distribution	O
.	O
</s>
<s>
The	O
logarithm	O
transformation	O
may	O
help	O
to	O
overcome	O
cases	O
where	O
the	O
Kolmogorov	B-General_Concept
test	I-General_Concept
data	O
does	O
not	O
seem	O
to	O
fit	O
the	O
assumption	O
that	O
it	O
came	O
from	O
the	O
normal	O
distribution	O
.	O
</s>
<s>
Using	O
a	O
moment	O
fit	O
or	O
KS	O
minimization	O
instead	O
has	O
a	O
large	O
impact	O
on	O
the	O
critical	O
values	O
,	O
and	O
also	O
some	O
impact	O
on	O
test	O
power	B-General_Concept
.	O
</s>
<s>
If	O
we	O
need	O
to	O
decide	O
for	O
Student-T	O
data	O
with	O
df	O
=	O
2	O
via	O
KS	B-General_Concept
test	I-General_Concept
whether	O
the	O
data	O
could	O
be	O
normal	O
or	O
not	O
,	O
then	O
a	O
ML	O
estimate	O
based	O
on	O
H0	O
(	O
data	O
is	O
normal	O
,	O
so	O
using	O
the	O
standard	O
deviation	O
for	O
scale	O
)	O
would	O
give	O
much	O
larger	O
KS	O
distance	O
,	O
than	O
a	O
fit	O
with	O
minimum	O
KS	O
.	O
</s>
<s>
In	O
the	O
Student-T	O
case	O
,	O
a	O
modified	O
KS	B-General_Concept
test	I-General_Concept
with	O
KS	O
estimate	O
instead	O
of	O
MLE	O
,	O
makes	O
the	O
KS	B-General_Concept
test	I-General_Concept
indeed	O
slightly	O
worse	O
.	O
</s>
<s>
However	O
,	O
in	O
other	O
cases	O
,	O
such	O
a	O
modified	O
KS	B-General_Concept
test	I-General_Concept
leads	O
to	O
slightly	O
better	O
test	O
power	B-General_Concept
.	O
</s>
<s>
Under	O
the	O
assumption	O
that	O
is	O
non-decreasing	O
and	O
right-continuous	O
,	O
with	O
countable	O
(	O
possibly	O
infinite	O
)	O
number	O
of	O
jumps	O
,	O
the	O
KS	B-General_Concept
test	I-General_Concept
statistic	O
can	O
be	O
expressed	O
as	O
:	O
</s>
<s>
From	O
the	O
right-continuity	O
of	O
,	O
it	O
follows	O
that	O
and	O
and	O
hence	O
,	O
the	O
distribution	O
of	O
depends	O
on	O
the	O
null	B-General_Concept
distribution	I-General_Concept
,	O
i.e.	O
,	O
is	O
no	O
longer	O
distribution-free	B-General_Concept
as	O
in	O
the	O
continuous	O
case	O
.	O
</s>
<s>
Therefore	O
,	O
a	O
fast	O
and	O
accurate	O
method	O
has	O
been	O
developed	O
to	O
compute	O
the	O
exact	O
and	O
asymptotic	O
distribution	O
of	O
when	O
is	O
purely	O
discrete	O
or	O
mixed	O
,	O
implemented	O
in	O
C++	O
and	O
in	O
the	O
KSgeneral	O
package	O
of	O
the	O
R	B-Language
language	I-Language
.	O
</s>
<s>
The	O
functions	O
disc_ks_test( )	O
,	O
mixed_ks_test( )	O
and	O
cont_ks_test( )	O
compute	O
also	O
the	O
KS	B-General_Concept
test	I-General_Concept
statistic	O
and	O
p-values	O
for	O
purely	O
discrete	O
,	O
mixed	O
or	O
continuous	O
null	B-General_Concept
distributions	I-General_Concept
and	O
arbitrary	O
sample	O
sizes	O
.	O
</s>
<s>
The	O
KS	B-General_Concept
test	I-General_Concept
and	O
its	O
p-values	O
for	O
discrete	O
null	B-General_Concept
distributions	I-General_Concept
and	O
small	O
sample	O
sizes	O
are	O
also	O
computed	O
in	O
as	O
part	O
of	O
the	O
dgof	O
package	O
of	O
the	O
R	B-Language
language	I-Language
.	O
</s>
<s>
The	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
test	I-General_Concept
may	O
also	O
be	O
used	O
to	O
test	O
whether	O
two	O
underlying	O
one-dimensional	O
probability	O
distributions	O
differ	O
.	O
</s>
<s>
where	O
and	O
are	O
the	O
empirical	B-General_Concept
distribution	I-General_Concept
functions	I-General_Concept
of	O
the	O
first	O
and	O
the	O
second	O
sample	O
respectively	O
,	O
and	O
is	O
the	O
supremum	O
function	O
.	O
</s>
<s>
Note	O
that	O
the	O
two-sample	B-General_Concept
test	I-General_Concept
checks	O
whether	O
the	O
two	O
data	O
samples	O
come	O
from	O
the	O
same	O
distribution	O
.	O
</s>
<s>
A	O
shortcoming	O
of	O
the	O
univariate	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
test	I-General_Concept
is	O
that	O
it	O
is	O
not	O
very	O
powerful	O
because	O
it	O
is	O
devised	O
to	O
be	O
sensitive	O
against	O
all	O
possible	O
types	O
of	O
differences	O
between	O
two	O
distribution	O
functions	O
.	O
</s>
<s>
Some	O
argue	O
that	O
the	O
Cucconi	B-General_Concept
test	I-General_Concept
,	O
originally	O
proposed	O
for	O
simultaneously	O
comparing	O
location	O
and	O
scale	O
,	O
can	O
be	O
much	O
more	O
powerful	O
than	O
the	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
test	I-General_Concept
when	O
comparing	O
two	O
distribution	O
functions	O
.	O
</s>
<s>
While	O
the	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
test	I-General_Concept
is	O
usually	O
used	O
to	O
test	O
whether	O
a	O
given	O
F(x )	O
is	O
the	O
underlying	O
probability	O
distribution	O
of	O
Fn(x )	O
,	O
the	O
procedure	O
may	O
be	O
inverted	O
to	O
give	O
confidence	O
limits	O
on	O
F(x )	O
itself	O
.	O
</s>
<s>
A	O
distribution-free	B-General_Concept
multivariate	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
goodness	O
of	O
fit	O
test	O
has	O
been	O
proposed	O
by	O
Justel	O
,	O
Peña	O
and	O
Zamar	O
(	O
1997	O
)	O
.	O
</s>
<s>
The	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
test	I-General_Concept
statistic	O
needs	O
to	O
be	O
modified	O
if	O
a	O
similar	O
test	O
is	O
to	O
be	O
applied	O
to	O
multivariate	B-General_Concept
data	I-General_Concept
.	O
</s>
<s>
One	O
approach	O
to	O
generalizing	O
the	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
statistic	I-General_Concept
to	O
higher	O
dimensions	O
which	O
meets	O
the	O
above	O
concern	O
is	O
to	O
compare	O
the	O
cdfs	O
of	O
the	O
two	O
samples	O
with	O
all	O
possible	O
orderings	O
,	O
and	O
take	O
the	O
largest	O
of	O
the	O
set	O
of	O
resulting	O
KS	O
statistics	O
.	O
</s>
<s>
In	O
one	O
dimension	O
,	O
the	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
statistic	I-General_Concept
is	O
identical	O
to	O
the	O
so-called	O
star	O
discrepancy	O
D	O
,	O
so	O
another	O
native	O
KS	O
extension	O
to	O
higher	O
dimensions	O
would	O
be	O
simply	O
to	O
use	O
D	O
also	O
for	O
higher	O
dimensions	O
.	O
</s>
<s>
In	O
2021	O
the	O
functional	O
form	O
of	O
the	O
multivariate	O
KS	B-General_Concept
test	I-General_Concept
statistic	O
was	O
proposed	O
,	O
which	O
simplified	O
the	O
problem	O
of	O
estimating	O
the	O
tail	O
probabilities	O
of	O
the	O
multivariate	O
KS	B-General_Concept
test	I-General_Concept
statistic	O
,	O
which	O
is	O
needed	O
for	O
the	O
statistical	O
test	O
.	O
</s>
<s>
The	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
test	I-General_Concept
is	O
implemented	O
in	O
many	O
software	O
programs	O
.	O
</s>
<s>
Mathematica	B-Language
has	O
.	O
</s>
<s>
MATLAB	B-Language
's	O
Statistics	O
Toolbox	O
has	O
and	O
for	O
one-sample	O
and	O
two-sample	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
tests	I-General_Concept
,	O
respectively	O
.	O
</s>
<s>
The	O
R	B-Language
package	O
"	O
KSgeneral	O
"	O
computes	O
the	O
KS	B-General_Concept
test	I-General_Concept
statistics	O
and	O
its	O
p-values	O
under	O
arbitrary	O
,	O
possibly	O
discrete	O
,	O
mixed	O
or	O
continuous	O
null	B-General_Concept
distribution	I-General_Concept
.	O
</s>
<s>
R	B-Language
's	O
statistics	O
base-package	O
implements	O
the	O
test	O
as	O
in	O
its	O
"	O
stats	O
"	O
package	O
.	O
</s>
<s>
SAS	B-Language
implements	O
the	O
test	O
in	O
its	O
PROC	O
NPAR1WAY	O
procedure	O
.	O
</s>
<s>
In	O
Python	B-Language
,	O
the	O
SciPy	B-Application
package	O
implements	O
the	O
test	O
in	O
the	O
scipy.stats.kstest	O
function	O
.	O
</s>
<s>
Java	B-Language
has	O
an	O
implementation	O
of	O
this	O
test	O
provided	O
by	O
Apache	B-Language
Commons	I-Language
.	O
</s>
<s>
KNIME	B-Language
has	O
a	O
node	O
implementing	O
this	O
test	O
based	O
on	O
the	O
above	O
Java	B-Language
implementation	O
.	O
</s>
<s>
Julia	B-Application
has	O
the	O
package	O
with	O
the	O
function	O
ExactOneSampleKSTest( 	O
x::AbstractVector	O
{	O
<	O
:Real	O
}	O
,	O
d::UnivariateDistribution	O
)	O
.	O
</s>
<s>
StatsDirect	B-Algorithm
(	O
StatsDirect	B-Algorithm
Ltd	O
,	O
Manchester	O
,	O
UK	O
)	O
implements	O
.	O
</s>
<s>
Stata	B-Algorithm
(	O
Stata	B-Algorithm
Corporation	O
,	O
College	O
Station	O
,	O
TX	O
)	O
implements	O
the	O
test	O
in	O
ksmirnov	O
(	O
Kolmogorov	B-General_Concept
–	I-General_Concept
Smirnov	I-General_Concept
equality-of-distributions	O
test	O
)	O
command	O
.	O
</s>
<s>
PSPP	B-Language
implements	O
the	O
test	O
in	O
its	O
(	O
or	O
using	O
KS	O
shortcut	O
function	O
)	O
.	O
</s>
<s>
The	O
Real	O
Statistics	O
Resource	O
Pack	O
for	O
Excel	B-Application
runs	O
the	O
test	O
as	O
KSCRIT	O
and	O
KSPROB	O
.	O
</s>
