Why do I receive the error message 'CDF must not have duplicate X values' while using the KTEST function from the Statistics Toolbox 6.0 (R2007a)?

I use the result of an ECDF computation as input for KTEST:
n=20;
[f,x] = ecdf(rand(1,n));
d=diff(sort(x));
[h,p] = kstest(rand(1,n),[x f], 0.05);
I receive the following error:
??? Error using ==> kstest at 138
CDF must not have duplicate X values.

 Accepted Answer

The error message is caused by the fact that the first two elements of the ouput 'x' of the function ECDF are identical.
To workaround the error message use 'x(2:end)' as input data instead. You may have to change the size of other parameters too, e.g. size of F.

More Answers (0)

Products

Release

R2007a

Community Treasure Hunt

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

Start Hunting!