This was inspired by kstest2 from the matlab statistics toolbox.
Works from medium to large sample sizes, look at the references in the code.
This does not seem to work correctly. As a test I ran cmtest2(random('Normal',0,1,1,4000000),random('Normal',0,1,1,4000000)) that's 4 million samples from the same normal distribution and I got a p value of .067.
I wrote this a while ago. I don't recall at the moment. I will look into it as soon as possible.
Thanks for the feedback.
Which equation in academic reference (1) does the formula for 'CMstatistic' on line 143 refer to? Equation (6) in "On the distribution of the two-sample Cramer-von Mises criterion" looks very different.
I will look into both issues. Thanks for the feedback.
In the case that "CM_limiting_stat > z(end)" it is incorrect to report a pValue of 0. Instead it should be reported that p is less than .001
Good function! Why does the help documentation show a 4th input argument "tail" that isn't accepted by the function?
Thank you so much, works great.
I've uploaded a new and improved version. Corrected a bug in the rejection rule, as pointed out in the comments. Now it works as intended. Added an example along with an extensive test and a comparison with the Kolgomorov-Smirnov test provided by Matlab.
Yeah, someone pointed this out earlier too. As soon as I get time I will check it, and provide a test sequence too.
Thanks guys for the feedback.
I think Soma is right. pValue should be 1-pValue. Then we reject H_null when alpha > pValue.
Thanx, it is very useful.
the hypothesis is computed as "not(alpha>pValue)", is this correct?
i suppose it should be "H=(alpha>pValue)"
I think, the problem is not with reversing the boolean decision. The tables in reference (2), what is given is the CDF. So, the p-value is 1-p(T<T*), where T* is the observed/computed statistics.
I think, the p-value is actually 1-pValue* where pValue* is what is currently computed this function.
Please let me know if I am wrong
thanks for the feedback guys. ive expanded the documentation and corrected one bug with the boolean output. let me know if you find something else.
Very useful and clear to understand.
Thanks very much.
thank you it is exactly what i want
Corrected a bug in the rejection rule, as pointed out in the comments. Now it works as intented. Added an example along with an extensive test and comparison with the Kolgomorov-Smirnov test.
Corrected a bug in the rejection rule, as pointed out in the comments. Now it works as intented. Added an example along with an extensive test.
The boolean output of the test was reversed. Although the probability was correctly computed, the test rejected the null hypothesis when it had to accept it and vice versa.
Description was incomplete.