Overload List
| # | Signature | Description |
|---|---|---|
| 1 | function GOFKolmogorov(const Data1: TVec; const Data2: TVec; out hRes: THypothesisResult; out Signif: Double; hType: THypothesisType; Alpha: Double): Double; | Two sample Kolmogorov-Smirnov GOF test. |
| 2 | function GOFKolmogorov(const Data: TVec; out hRes: THypothesisResult; out Signif: Double; const CDFx: TVec; const CDFy: TVec; hType: THypothesisType; Alpha: Double): Double; | One sample Kolmogorov-Smirnov GOF test. |
Overload 1: function GOFKolmogorov(const Data1: TVec; const Data2: TVec; out hRes: THypothesisResult; out Signif: Double; hType: THypothesisType; Alpha: Double): Double;
Two sample Kolmogorov-Smirnov GOF test.
| # | Name | Description |
|---|---|---|
| 1 | Data1 | First dataset. |
| 2 | Data2 | Second dataset. |
| 3 | hRes | Returns the result of the null hypothesis (default assumption is that data comes from specific distribution). |
| 4 | hType | Defines the type of the null hypothesis (left, right and two - tailed). |
| 5 | Signif | (Significance level) returns the probability of observing the given result by chance given that the null hypothesis is true. |
| 6 | Alpha | Defines the desired significance level. If the significance probability (Signif) is below the desired significance (Alpha), the null hypothesis is rejected. |
Returns: Double - K-S statistics.
Performs two-sample Kolmogorov-Smirnov goodnes of fit test on indepentent random samples Data1 and Data2. Test determines if Data1 and Data2 samples are drawn from the same continuous population.
Uses MtxExpr, Math387, Statistics;
procedure Example1;
var d1,d2: Vector;
hres:THypothesisResult;
signif, KS: double;
begin
// Note that d1 and d2 lengths don't have to he equal.
d1.Size(30);
d2.Size(22);
RandomWeibull(2,3,d1,-1);
RandomNormal(2,1,d2,-1);
KS := GOFKolmogorov(d1,d2, hRes, Signif, htTwoTailed, 0.05);
// Result should be significance below 0.05 meaning d1 and d2 values
// do not come from same distribution
Overload 2: function GOFKolmogorov(const Data: TVec; out hRes: THypothesisResult; out Signif: Double; const CDFx: TVec; const CDFy: TVec; hType: THypothesisType; Alpha: Double): Double;
One sample Kolmogorov-Smirnov GOF test.
| # | Name | Description |
|---|---|---|
| 1 | Data | Samples to be tested. |
| 2 | CDFx | Defines set of possible x values. |
| 3 | CDFy | Defines set of hypothesized CDF values, evaluated at CDFx. |
| 4 | hRes | Returns the result of the null hypothesis (default assumption is that data comes from specific distribution). |
| 5 | hType | Defines the type of the null hypothesis (left, right and two - tailed). |
| 6 | Signif | (Significance level) returns the probability of observing the given result by chance given that the null hypothesis is true. |
| 7 | Alpha | Defines the desired significance level. If the significance probability (Signif) is bellow the desired significance (Alpha), the null hypothesis is rejected. |
Returns: Double - K-S statistics.
Performs one-sample Kolmogorov-Smirnov (KS) goodnes of fit test. The KS test is used to decide if a sample comes from a population with a specific distribution. Test is based on the empirical distribution function (ECDF). An attractive feature of this test is that the distribution of the K-S test statistic itself does not depend on the underlying cumulative distribution function being tested. Another advantage is that it is an exact test (the chi-square goodness-of-fit test depends on an adequate sample size for the approximations to be valid). Despite these advantages, the K-S test has several important limitations:
- It only applies to continuous distributions.
- It tends to be more sensitive near the center of the distribution than at the tails.
- Perhaps the most serious limitation is that the distribution must be fully specified. That is, if location, scale, and shape parameters are estimated from the data, the critical region of the K-S test is no longer valid. It typically must be determined by simulation.
If CDFx and CDFy vectors are not defined, Data values are compared with standard normal distribution. If defined, CDFx and CDfy vectors represent hypothesized distribution x and CDF(x) values. In this case all Data values must lie within the [Min(CDFx),Max(CDFx)] interval. The KS test assumes CDFx and CDFy are predefined - KS test is not very accurate if CDFx and CDFy values are calculated from Data values.
Uses MtxExpr, Math387, Statistics;
procedure Example;
var d: Vector;
hres:THypothesisResult;
signif, KS: double;
begin
d.Size(300);
RandomNormal(2,1,d,-1);
KS := GOFKolmogorov(d, hRes, Signif, nil, nil, htTwoTailed, 0.05);
// Result should be significance above 0.05 meaning d values
// are normally distributed.