Code covered by the BSD License  

Highlights from
Two sample Cramer-von Mises hypothesis test

4.375

4.4 | 10 ratings Rate this file 19 Downloads (last 30 days) File Size: 4.44 KB File ID: #13407

Two sample Cramer-von Mises hypothesis test

by

 

15 Dec 2006 (Updated )

A non parametric test to determine if to independent samples were drawn from the same distribution.

| Watch this File

File Information
Description

This was inspired by kstest2 from the matlab statistics toolbox.
Works from medium to large sample sizes, look at the references in the code.

Required Products Statistics Toolbox
MATLAB release MATLAB 7 (R14)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (18)
08 May 2014 Jon

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.

08 May 2014 Jon  
24 Apr 2014 Ruisi  
27 Jul 2013 Juan Cardelino

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.

29 Nov 2012 Dan

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.

06 Nov 2012 Juan Cardelino

I will look into both issues. Thanks for the feedback.

06 Nov 2012 Stuart Layton

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

06 Nov 2012 Stuart Layton

Good function! Why does the help documentation show a 4th input argument "tail" that isn't accepted by the function?

18 May 2012 Ipek

Thank you so much, works great.

16 Nov 2011 Juan Cardelino

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.

30 Dec 2009 Juan Cardelino

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.

29 Dec 2009 Siavash Jalal

I think Soma is right. pValue should be 1-pValue. Then we reject H_null when alpha > pValue.

25 Dec 2009 priya priyal

hi juan,
Thanx, it is very useful.

the hypothesis is computed as "not(alpha>pValue)", is this correct?
i suppose it should be "H=(alpha>pValue)"

17 Oct 2009 Soma

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

26 May 2009 Juan Cardelino

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.

11 May 2008 Negar M

Very useful and clear to understand.
Thanks very much.

03 Jan 2008 Min Lee

Thank you~

05 Aug 2007 patrick li

thank you it is exactly what i want

Updates
09 Jan 2007

Description was incomplete.

26 May 2009

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.

16 Nov 2011

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.

16 Nov 2011

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.

Contact us