Re: Chi2cdf and gamma functions evaluation
- From: "us " <us@xxxxxxxxxxxxxxx>
- Date: Sat, 18 Jul 2009 20:57:00 +0000 (UTC)
"Benny Guralnik" <none@xxxxxxxxx> wrote in message <h3t6rt$p42$1@xxxxxxxxxxxxxxxxxx>...
Hi all,
By definition the cumulative chi square distribution is a function of x (the chi-squared value) and v (degrees of freedom)
chi2dist(x,v)
should be equal to:
gammainc(x/2,v/2)/gamma(v/2)
I'm getting similar results for both when x and v are small (1,2,3...), however even for, say x=3 and v=9 the gamma formulation greatly deviates from its true value.
Is that connected to how the gamma function in matlab is numerically evaluated?
Thanks,
Benny
a thought:
help chi2cdf;
%{
....
The chi-square density function with V degrees of freedom,
is the same as a gamma density function with parameters V/2 and 2.
....
%}
% hence
x=(1:10).';
v=10;
r=[x,chi2cdf(x,v),gammainc(x/2,v/2)/gamma(2)]
%{
1 0.000172116 0.000172116
2 0.00365985 0.00365985
3 0.0185759 0.0185759
4 0.052653 0.052653
5 0.108822 0.108822
6 0.184737 0.184737
7 0.274555 0.274555
8 0.371163 0.371163
9 0.467896 0.467896
10 0.559507 0.559507
%}
isequal(r(:,2),r(:,3))
% ans = 1 % <- true
us
.
- References:
- Chi2cdf and gamma functions evaluation
- From: Benny Guralnik
- Chi2cdf and gamma functions evaluation
- Prev by Date: Re: Solving a transcendental equation
- Next by Date: object oriented programming (beginner's question)
- Previous by thread: Chi2cdf and gamma functions evaluation
- Next by thread: Box car Filter
- Index(es):
Relevant Pages
|
Loading