Two sample Kolmogorov-Smirnov GOF test.
function GOFKolmogorov(const Data1: TVec; const Data2: TVec; out hRes: THypothesisResult; out Signif: double; hType: THypothesisType = htTwoTailed; Alpha: double = 0.05): double; overload;
Parameters |
Description |
Data1 |
First dataset. |
Data2 |
Second dataset. |
hRes |
Returns the result of the null hypothesis (default assumption is that data comes from specific distribution). |
Signif |
(Significance level) returns the probability of observing the given result by chance given that the null hypothesis is true. |
hType |
Defines the type of the null hypothesis (left, right and two - tailed). |
Alpha |
Defines the desired significance level. If the significance probability (Signif) is below the desired significance (Alpha), the null hypothesis is rejected. |
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.
In this example two differently sized samples are generated using diferent Weibull(a=2,b=3) and Normal(mu=2,sigma=1) distributions. Then a KS test is used to determine if both samples come from the same distribution.
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
#include "MtxExpr.hpp" #include "Math387.hpp" #include "Statistics.hpp" void __fastcall Example1() { THypothesisResult hres; double signif, KS; sVector d1, d2; d1.Length = 30; d2.Length = 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 }
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
|
What do you think about this topic? Send feedback!
|