Viewing 1 post (of 1 total)
  • Author
    Posts
  • #423

    shakuntala
    Participant

    % chiprob.m
    % @shortDesc: Distribucion CHI^2 . Enviado por M. Urrutia MD, PhD.
    % @fullDesc: Usa un algoritmo de expansión en serie para el cálculo de probabilidades exactas de la distribucion CHI^2 en funcion de V grados de libertad P(X>=x).Ref. Abramowit and Stegun. Handbook of Mathematical Functions. Dover Publications Inc. NY
    % z=chiprob(Chivalue,GL)
    function [xp] =chiprob(x,y)

    n1 = power(10,-100);
    n2 = power(10,100);
    denom = 1;
    chisqr= x;
    df = y;
    dx = y;
    vx =y;
    parity=0.0;
    while df >=2
    denom = denom * df;
    df = df -2;
    end
    numer=power(chisqr,(floor((vx+1)/2))) *exp(-chisqr / 2) / denom;
    if round(vx/2) != (vx/2 )
    parity = sqrt(2 / chisqr / pi);
    else
    parity = 1.0;
    end
    s = 1.0;
    t= 1.0;
    while t > 0.0000001
    dx = dx + 2;
    t = t * chisqr/ dx;
    s = s + t;
    if ((s<= n1) | (s >= n2)) | ((t <= n1) | (t>= n2 ))
    end
    end
    %limite superior
    xp = 1-abs((parity*numer*s));
    end

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.