필터 지우기
필터 지우기

how interpret Kolmogrov test outputs?

조회 수: 9 (최근 30일)
Mar Ta
Mar Ta 2017년 9월 9일
Hello, I want to use kstest2 function to see whether my samples have same distribution or not.
[h,p,ks2stat] = kstest2(x1,x2);
i tested different samples and all the time i got h = 1 and p = 0 as output, but ks2stat output changes for different tests. my question is that what is ks2stat and how it changes between different samples. can i use it to get in to any conclusion about samples? if YES, how?
thanks

답변 (2개)

dpb
dpb 2017년 9월 9일
편집: dpb 2017년 9월 9일
h,p are the results of the hypothesis test at the (default) 5% significance level-- h is a logical "pass/fail" flag while p is the estimated significance for the specific test evaluated; the last optional argument is the actual computed statistic.
If the null hypothesis that the two distributions are from the same parent distribution cannot be rejected at the chosen significance level h will be 0 (False); otherwise it will be 1 (True). If your cases all are [1,0] for the first two, that indicates there's such a large dichotomy between the two cases that the estimate of the probability is so far out into the tail that it is approximately 0 to the precision shown by default. That the actual statistic is somewhat different shows that the data aren't actually identically the same.
Look at the first example in the documentation but then make a simple change/extension to it--
>> rng(1); % For reproducibility
x1 = wblrnd(1,1,1,50); % sample from Weibel
x2 = wblrnd(1.2,2,1,50); % sample different distribution
>> [h,p,ks2]=kstest2(x1,x2) % output -- they're different; p=0.03 < 0.05 default
h =
1
p =
0.0317
ks2 =
0.2800
>> x2 = wblrnd(1,1,1,50); % make second distribution from same parameters as first
>> [h,p,ks2]=kstest2(x1,x2) % can't tell they're different; as expected.
h =
0
p =
0.8409
ks2 =
0.1200
>>
Read the extended help More About sections for background on the test itself; references in the statistical literature are also given altho any competent statistics text that includes nonparametric tests will cover it in some depth.

Albert Johan Mamani Larico
Albert Johan Mamani Larico 2022년 4월 1일
편집: Albert Johan Mamani Larico 2022년 4월 1일
My understading about it is:
-h : is the result of the comparison of 2 vectors (h=0 means equal distribution, h=1 means diferent distributions)
-p : is the p-value or the level of confidence of the results(which depend on the number of data in each vector)
-ks2stat: is the test statistic D(maximum difference between empirical distribution functions) in the original equation of the KS test, which is used for h estimation

카테고리

Help CenterFile Exchange에서 Hypothesis Tests에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by