<< Chi-Squared Chi-Squared distfun_chi2inv >>

distfun >> distfun > Chi-Squared > distfun_chi2cdf

distfun_chi2cdf

Chi-squared CDF

Calling Sequence

p = distfun_chi2cdf(x,k)
p = distfun_chi2cdf(x,k,lowertail)

Parameters

x :

a matrix of doubles, the outcome, greater or equal to zero

k :

a matrix of doubles, the number of degrees of freedom, k>0 (can be non integer)

lowertail :

a 1-by-1 matrix of booleans, the tail (default lowertail=%t). If lowertail is true (the default), then considers P(X<=x) otherwise P(X>x).

p :

a matrix of doubles, the probability.

Description

Computes the cumulative distribution function of the Chi-squared distribution function.

Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.

Examples

// Test with x scalar, k scalar
computed = distfun_chi2cdf(4,5)
expected = 0.4505840

// Test with expanded x, k scalar
computed = distfun_chi2cdf([2 6],5)
expected = [0.1508550 0.6937811]

// Test with x scalar, k expanded
computed = distfun_chi2cdf(4,[4 7])
expected = [0.5939942 0.2202226]

// Test with both x,k expanded
computed = distfun_chi2cdf([2 6],[3 4])
expected = [0.4275933 0.8008517]

// Plot the function
h=scf();
k = [2 3 4 6 9 12];
cols = [1 2 3 4 5 6];
lgd = [];
for i = 1:size(k,'c')
x = linspace(0,10,1000);
y = distfun_chi2cdf ( x , k(i) );
plot(x,y)
str = msprintf("k=%s",string(k(i)));
lgd($+1) = str;
end
for i = 1:size(k,'c')
hcc = h.children.children;
hcc.children(size(k,'c') - i + 1).foreground = cols(i);
end
xtitle("Chi-squared CDF","x","$P(X\leq x)$");
legend(lgd);

Bibliography

http://en.wikipedia.org/wiki/Chi-squared_distribution

Authors


Report an issue
<< Chi-Squared Chi-Squared distfun_chi2inv >>