KolmogorovSmirnovDistribution Class |
Namespace: Accord.Statistics.Distributions.Univariate
[SerializableAttribute] public class KolmogorovSmirnovDistribution : UnivariateContinuousDistribution, IFormattable
The KolmogorovSmirnovDistribution type exposes the following members.
Name | Description | |
---|---|---|
KolmogorovSmirnovDistribution |
Creates a new Kolmogorov-Smirnov distribution.
|
Name | Description | |
---|---|---|
Entropy |
Gets the entropy for this distribution.
(Overrides UnivariateContinuousDistributionEntropy.) | |
Mean |
Gets the mean for this distribution.
(Overrides UnivariateContinuousDistributionMean.) | |
Median |
Gets the median for this distribution.
(Inherited from UnivariateContinuousDistribution.) | |
Mode |
Not supported.
(Overrides UnivariateContinuousDistributionMode.) | |
NumberOfSamples |
Gets the number of samples distribution parameter.
| |
Quartiles |
Gets the Quartiles for this distribution.
(Inherited from UnivariateContinuousDistribution.) | |
StandardDeviation |
Gets the Standard Deviation (the square root of
the variance) for the current distribution.
(Inherited from UnivariateContinuousDistribution.) | |
Support |
Gets the support interval for this distribution.
(Overrides UnivariateContinuousDistributionSupport.) | |
Variance |
Gets the variance for this distribution.
(Overrides UnivariateContinuousDistributionVariance.) |
Name | Description | |
---|---|---|
Clone |
Creates a new object that is a copy of the current instance.
(Overrides DistributionBaseClone.) | |
ComplementaryDistributionFunction(Double) |
Gets the complementary cumulative distribution function
(ccdf) for this distribution evaluated at point x.
This function is also known as the Survival function.
(Inherited from UnivariateContinuousDistribution.) | |
ComplementaryDistributionFunction(Double, Double) |
Computes the Complementary Cumulative Distribution Function (1-CDF)
for the Kolmogorov-Smirnov statistic's distribution.
| |
CumulativeFunction |
Computes the Cumulative Distribution Function (CDF)
for the Kolmogorov-Smirnov statistic's distribution.
| |
CumulativeHazardFunction |
Gets the cumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.) | |
DistributionFunction(Double) |
Gets the cumulative distribution function (cdf) for
this distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.) | |
DistributionFunction(Double, Double) |
Gets the cumulative distribution function (cdf) for this
distribution in the semi-closed interval (a; b] given as
P(a < X ≤ b).
(Inherited from UnivariateContinuousDistribution.) | |
Durbin |
Durbin's algorithm for computing P[Dn < d]
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
Fit(Double) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.) | |
Fit(Double, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.) | |
Fit(Double, Double) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.) | |
Fit(Double, Int32) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.) | |
Fit(Double, Double, IFittingOptions) |
Not supported.
(Overrides UnivariateContinuousDistributionFit(Double, Double, IFittingOptions).) | |
Fit(Double, Int32, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.) | |
Generate |
Generates a random observation from the current distribution.
(Inherited from UnivariateContinuousDistribution.) | |
Generate(Int32) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateContinuousDistribution.) | |
Generate(Random) |
Generates a random observation from the current distribution.
(Inherited from UnivariateContinuousDistribution.) | |
Generate(Int32, Double) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateContinuousDistribution.) | |
Generate(Int32, Random) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateContinuousDistribution.) | |
Generate(Int32, Double, Random) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateContinuousDistribution.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetRange |
Gets the distribution range within a given percentile.
(Inherited from UnivariateContinuousDistribution.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
HazardFunction |
Gets the hazard function, also known as the failure rate or
the conditional failure density function for this distribution
evaluated at point x.
(Inherited from UnivariateContinuousDistribution.) | |
InnerComplementaryDistributionFunction |
Gets the complementary cumulative distribution function
(ccdf) for this distribution evaluated at point x.
This function is also known as the Survival function.
(Overrides UnivariateContinuousDistributionInnerComplementaryDistributionFunction(Double).) | |
InnerDistributionFunction |
Gets the cumulative distribution function (cdf) for
this distribution evaluated at point x.
(Overrides UnivariateContinuousDistributionInnerDistributionFunction(Double).) | |
InnerInverseDistributionFunction |
Gets the inverse of the cumulative distribution function (icdf) for
this distribution evaluated at probability p. This function
is also known as the Quantile function.
(Inherited from UnivariateContinuousDistribution.) | |
InnerLogProbabilityDensityFunction |
Gets the log-probability density function (pdf) for
this distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.) | |
InnerProbabilityDensityFunction |
Not supported.
(Overrides UnivariateContinuousDistributionInnerProbabilityDensityFunction(Double).) | |
InverseDistributionFunction |
Gets the inverse of the cumulative distribution function (icdf) for
this distribution evaluated at probability p. This function
is also known as the Quantile function.
(Inherited from UnivariateContinuousDistribution.) | |
LogCumulativeHazardFunction |
Gets the log of the cumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.) | |
LogProbabilityDensityFunction |
Gets the log-probability density function (pdf) for
this distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OneSideDistributionFunction |
Computes the Upper Tail of the P[Dn >= x] distribution.
| |
OneSideUpperTail |
Computes the Upper Tail of the P[Dn >= x] distribution.
| |
PelzGood |
Pelz-Good algorithm for computing lower-tail areas
of the Kolmogorov-Smirnov distribution.
| |
Pomeranz |
Pomeranz algorithm.
| |
ProbabilityDensityFunction |
Gets the probability density function (pdf) for
this distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.) | |
QuantileDensityFunction |
Gets the first derivative of the
inverse distribution function (icdf) for this distribution evaluated
at probability p.
(Inherited from UnivariateContinuousDistribution.) | |
ToString |
Returns a String that represents this instance.
(Inherited from DistributionBase.) | |
ToString(IFormatProvider) |
Returns a String that represents this instance.
(Inherited from DistributionBase.) | |
ToString(String) |
Returns a String that represents this instance.
(Inherited from DistributionBase.) | |
ToString(String, IFormatProvider) |
Returns a String that represents this instance.
(Overrides DistributionBaseToString(String, IFormatProvider).) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
This class is based on the excellent paper and original Java code by Simard and L'Ecuyer (2010). Includes additional modifications for increased performance and readability, shared under the LGPL under permission of original authors.
L'Ecuyer and Simard partitioned the problem of evaluating the CDF using multiple approximation and asymptotic methods in order to achieve a best compromise between speed and precision. The distribution function of this class follows the same partitioning scheme as described by L'Ecuyer and Simard, which is described in the table below.
For n <= 140 and: | |
---|---|
1/n > x >= 1-1/n | Uses the Ruben-Gambino formula. |
1/n < nx² < 0.754693 | Uses the Durbin matrix algorithm. |
0.754693 <= nx² < 4 | Uses the Pomeranz algorithm. |
4 <= nx² < 18 | Uses the complementary distribution function. |
nx² >= 18 | Returns the constant 1. |
For 140 < n <= 10^5 | |
---|---|
nx² >= 18 | Returns the constant 1. |
nx^(3/2) < 1.4 | Durbin matrix algorithm. |
nx^(3/2) > 1.4 | Pelz-Good asymptotic series. |
For n > 10^5 | |
---|---|
nx² >= 18 | Returns the constant 1. |
nx² < 18 | Pelz-Good asymptotic series. |
References:
The following example shows how to build a Kolmogorov-Smirnov distribution for 42 samples and compute its main functions and characteristics:
// Create a Kolmogorov-Smirnov distribution with n = 42 var ks = new KolmogorovSmirnovDistribution(samples: 42); // Common measures double mean = ks.Mean; // 0.13404812830261556 double median = ks.Median; // 0.12393613519421857 double var = ks.Variance; // 0.019154717445778062 // Cumulative distribution functions double cdf = ks.DistributionFunction(x: 0.27); // 0.99659863602996079 double ccdf = ks.ComplementaryDistributionFunction(x: 0.27); // 0.0034013639700392062 double icdf = ks.InverseDistributionFunction(p: cdf); // 0.26999997446092017 // Hazard (failure rate) functions double chf = ks.CumulativeHazardFunction(x: 0.27); // 5.6835787601476619 // String representation string str = ks.ToString(); // "KS(x; n = 42)"