Code covered by the BSD License  

Highlights from
Two sample Cramer-von Mises hypothesis test

5.0

5.0 | 5 ratings Rate this file 18 Downloads (last 30 days) File Size: 4.44 KB File ID: #13407

Two sample Cramer-von Mises hypothesis test

by Juan Cardelino

 

15 Dec 2006 (Updated 16 Nov 2011)

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  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
05 Aug 2007 patrick li

thank you it is exactly what i want

03 Jan 2008 Min Lee

Thank you~

11 May 2008 Negar M

Very useful and clear to understand.
Thanks very much.

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.

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

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)"

29 Dec 2009 Siavash Jalal

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

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.

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.

18 May 2012 Ipek

Thank you so much, works great.

Please login to add a comment or rating.
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.

Tag Activity for this File
Tag Applied By Date/Time
statistics Juan Cardelino 16 Nov 2011 11:56:58

Contact us at files@mathworks.com