code for computing the formular

3 vues (au cours des 30 derniers jours)
Tino
Tino le 10 Avr 2019
Modifié(e) : Tino le 8 Août 2019
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

Réponse acceptée

dpb
dpb le 10 Avr 2019
Modifié(e) : dpb le 10 Avr 2019
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

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Tags

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by