ranksum returns NaN when comparing two vectors with a single identical entry when sum of lengths is greater than 20
이전 댓글 표시
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)
답변 (2개)
Andrew Reibold
2013년 6월 3일
편집: Andrew Reibold
2013년 6월 3일
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
카테고리
도움말 센터 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!