ranksum returns NaN when comparing two vectors with a single identical entry when sum of lengths is greater than 20

5 visualizaciones (últimos 30 días)
I'm running a ranksum hypothesis test on multiple vectors.
Each test takes a column of a matrix and compares the top third to the rest of the column
ranksum(col(1:500),col(501:1500))
This is fine except when the column has only a single entry; it then returns NaN.
Consider the following simple example:
x=ones(20,1); y=ones(20,1); ranksum(x,y)
NaN
BUT I've noticed the following returns the expected result
x=ones(9,1); y=ones(9,1); ranksum(x,y)
ans = 1
I may be misunderstanding something about the way ranksum is calculated. Thanks in advance.
R2012b (64bit)

Respuestas (2)

Andrew Reibold
Andrew Reibold el 3 de Jun. de 2013
Editada: Andrew Reibold el 3 de Jun. de 2013
Hello Connor,
This is because the method of calculation changes depending on your inputs. (Exact Solution, Approximate Solution, or Old Exact Solution)
First it checks your inputs to see if needs to used the Old Exact solution which is a solution method that was more or less grandfathered in to this modern version of the function.
Aside from that
.
If the number of elements in both X and Y vectors combined is GREATER THAN 20
AND IF
One of the vectors has less than 10 elements
.
Then the EXACT method is used.
If it doesnt not meet these criteria, the Approximation method is used.
The exact details can be a bit lengthy, but if you want to see exactly how they are calculating it, go to the command window and type:
open ranksum
I hope his helps!
-Andrew

Conor
Conor el 4 de Jun. de 2013
Thanks for the answer, Andrew. I'll open it up and have a look. I'll post if I figure out a solution, for future reference.
-Conor

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by