code for computing the formular

조회 수: 6 (최근 30일)
Tino
Tino 2019년 4월 10일
편집: Tino 2019년 8월 8일
I have the set of numbers
(Si) = (0.25541156, 4.446482251, 0.389762062, 4.211214131)
(sj) = ( 0.25541156, 4.446482251, 0.389762062, 4.211214131)
pvalue = ( #( si greater than sj ) + 0.5 (si = sj) )/ i
when i = 1
I am trying to compute this steps
pvalue = 1 when i = 1 pvalue is always 1
si = sj = 1
when i = 2
J = 1 if s2 > sj1 = 1 pvalue = ( 1 + 0.5(1)) / 2 = 0.75
J = 2 s2 = sj2 = 1
for i = 3
J = 1 s3 > sj1 = 1
J = 2 s3 > sJ2 = 0 pvalue = (1 + 0.5 (1))/3 = 0.5
J= 3 s3 = sj3 = 1
for i = 4
J = 1 s4 > sj1 = 1
J = 2 S4 > Sj2 = 0 pvalue = 2 + 0.5(1)/4 = 0.625
J = 3 s4 > sj3 = 1
J = 4 s4 = sj4 = 1
I will appreciate it if I get a code to compute the various pvalue
jonathan

채택된 답변

dpb
dpb 2019년 4월 10일
편집: dpb 2019년 4월 10일
fnP=@(a,i) (sum(a(i)>a(1:i))+0.5*sum(a(i)==a(1:i)))/i;
>> for i=2:numel(Si),fnP(Si,i),end
ans =
0.75
ans =
0.50
ans =
0.63
>>
To wrap the i==1 special case got more than I could get into the anonymous function in the time I had to play...for general use write a little function--
function P=fnP(A,n)
% Return some undefined P-value estimator from vector A, number elements, n
if n==1
P==1;
else
P=(sum(A(n)>A(1:n)) + 0.5*sum(A(n)==A(1:n)))/n;
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by