Skip to content

Commit

Permalink
Merge branch 'smirnovi_stability' into kolmogsmirnov
Browse files Browse the repository at this point in the history
* smirnovi_stability:
  Added smirnovc/smirnovci, the CDF for the Smirnov probability distribution.
  Addresses scipy#7456, scipy#7426, scipy#7455 (scipy.special.smirnov, scipy.stats.ksone)
  scipy.special.{smirnov,smirnovi} have accuracy & convergence issues;
  incorrect values for scipy.stats.ksone.pdf()
  • Loading branch information
pvanmulbregt committed Sep 8, 2017
2 parents 4f0ac18 + 72cb467 commit bea77cb
Show file tree
Hide file tree
Showing 10 changed files with 749 additions and 108 deletions.
3 changes: 3 additions & 0 deletions scipy/special/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@
chndtrinc -- Inverse to `chndtr` vs `nc`
chndtrix -- Inverse to `chndtr` vs `x`
smirnov -- Kolmogorov-Smirnov complementary cumulative distribution function
smirnovc -- Kolmogorov-Smirnov cumulative distribution function
smirnovi -- Inverse to `smirnov`
smirnovic -- Inverse to `smirnovc`
smirnovp -- Derivative of `smirnov`
kolmogorov -- Complementary cumulative distribution function of Kolmogorov distribution
kolmogi -- Inverse function to kolmogorov
tklmbda -- Tukey-Lambda cumulative distribution function
Expand Down
3 changes: 3 additions & 0 deletions scipy/special/_generate_pyx.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@
pdtri -- pdtri: id->d, pdtri_unsafe: dd->d -- cephes.h, _legacy.pxd
yn -- yn: id->d, yn_unsafe: dd->d -- cephes.h, _legacy.pxd
smirnov -- smirnov: id->d, smirnov_unsafe: dd->d -- cephes.h, _legacy.pxd
smirnovc -- smirnovc: id->d, smirnovc_unsafe: dd->d -- cephes.h, _legacy.pxd
smirnovi -- smirnovi: id->d, smirnovi_unsafe: dd->d -- cephes.h, _legacy.pxd
smirnovci -- smirnovci: id->d, smirnovci_unsafe: dd->d -- cephes.h, _legacy.pxd
smirnovp -- smirnovp: id->d, smirnovp_unsafe: dd->d -- cephes.h, _legacy.pxd
agm -- agm: dd->d -- _agm.pxd
airy -- airy_wrap: d*dddd->*i, cairy_wrap: D*DDDD->*i -- amos_wrappers.h
itairy -- itairy_wrap: d*dddd->*i -- specfun_wrappers.h
Expand Down
17 changes: 17 additions & 0 deletions scipy/special/_legacy.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ cdef extern from "cephes.h":
double kn(int n, double x) nogil
double yn(int n, double x) nogil
double smirnov(int n, double e) nogil
double smirnovc(int n, double e) nogil
double smirnovi(int n, double p) nogil
double smirnovci(int n, double p) nogil
double smirnovp(int n, double p) nogil

cdef extern from "amos_wrappers.h":
double cbesk_wrap_real_int(int n, double z) nogil
Expand Down Expand Up @@ -89,9 +92,23 @@ cdef inline double kn_unsafe(double n, double x) nogil:
cdef inline double yn_unsafe(double n, double x) nogil:
_legacy_cast_check("yn", n, 0)
return yn(<int>n, x)

cdef inline double smirnov_unsafe(double n, double e) nogil:
_legacy_cast_check("smirnov", n, 0)
return smirnov(<int>n, e)

cdef inline double smirnovc_unsafe(double n, double e) nogil:
_legacy_cast_check("smirnovc", n, 0)
return smirnovc(<int>n, e)

cdef inline double smirnovi_unsafe(double n, double p) nogil:
_legacy_cast_check("smirnovi", n, 0)
return smirnovi(<int>n, p)

cdef inline double smirnovci_unsafe(double n, double p) nogil:
_legacy_cast_check("smirnovci", n, 0)
return smirnovci(<int>n, p)

cdef inline double smirnovp_unsafe(double n, double p) nogil:
_legacy_cast_check("smirnovp", n, 0)
return smirnovp(<int>n, p)
31 changes: 31 additions & 0 deletions scipy/special/add_newdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6356,6 +6356,20 @@ def add_newdoc(place, name, doc):
is greater than e.
""")

add_newdoc("scipy.special", "smirnovc",
"""
smirnovc(n, e)
Kolmogorov-Smirnov cumulative distribution function
Returns the exact Kolmogorov-Smirnov cumulative
distribution function (Dn+ or Dn-) for a one-sided test of
equality between an empirical and a theoretical distribution. It
is equal to the probability that the maximum difference between a
theoretical distribution and an empirical one based on `n` samples
is less than or equal to e.
""")

add_newdoc("scipy.special", "smirnovi",
"""
smirnovi(n, y)
Expand All @@ -6365,6 +6379,23 @@ def add_newdoc(place, name, doc):
Returns ``e`` such that ``smirnov(n, e) = y``.
""")

add_newdoc("scipy.special", "smirnovci",
"""
smirnovci(n, y)
Inverse to `smirnovc`
Returns ``e`` such that ``smirnovc(n, e) = y``.
""")

add_newdoc("scipy.special", "smirnovp",
"""
smirnovp(n, y)
Derivative of `smirnov`
""")


add_newdoc("scipy.special", "spence",
r"""
spence(z, out=None)
Expand Down
3 changes: 3 additions & 0 deletions scipy/special/cephes.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ extern double zeta ( double x, double q );
extern double zetac ( double x );

extern double smirnov (int n, double e );
extern double smirnovc (int n, double e );
extern double smirnovp (int n, double x );
extern double smirnovi (int n, double p );
extern double smirnovci (int n, double p );
extern double kolmogorov ( double x );
extern double kolmogi ( double p );

Expand Down
3 changes: 3 additions & 0 deletions scipy/special/cephes/cephes_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@
#define zeta cephes_zeta
#define zetac cephes_zetac
#define smirnov cephes_smirnov
#define smirnovc cephes_smirnovc
#define smirnovi cephes_smirnovi
#define smirnovci cephes_smirnovci
#define smirnovp cephes_smirnovp
#define kolmogorov cephes_kolmogorov
#define kolmogi cephes_kolmogi

Expand Down
Loading

0 comments on commit bea77cb

Please sign in to comment.