code for computing the formular

7 visualizaciones (últimos 30 días)
Tino
Tino el 10 de Abr. de 2019
Editada: Tino el 8 de Ag. de 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

Respuesta aceptada

dpb
dpb el 10 de Abr. de 2019
Editada: dpb el 10 de Abr. de 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

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by