code for computing the formular

1 回表示 (過去 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 Center および File ExchangeLogical についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by