Chi-squared inverse function and incomplete gamma function

In summary, the incomplete gamma function can be expressed as a product of the gamma function and the scaled inverse chi-squared distribution.
  • #1
onanox
15
0
is there a way to explicitly express the chi-squared inverse function?

when programming it, I have had to resort to a guessing system where I find a chi value that is too low and too high, and evaluate the chi-squared CDF to reset the high and low points iteratively until it is within a preset tolerance to the correct value.

However, this a clunky and inefficient method.

Additionally, for large degrees of freedom (50,000 or so) I can't even calculate the chi-squared CDF because the values are too high. I noticed that this function can be expressed as a ratio of the gamma function and incomplete gamma function, so It occurred to me to express the value as a difference of logs of each piece. However, I have only found expressions of the incomplete gamma function as sums, which are difficult (impossible?) to log. is there any way to express the incomplete gamma function as a product?
 
Physics news on Phys.org
  • #2
onanox said:
is there a way to explicitly express the chi-squared inverse function?

when programming it, I have had to resort to a guessing system where I find a chi value that is too low and too high, and evaluate the chi-squared CDF to reset the high and low points iteratively until it is within a preset tolerance to the correct value.

However, this a clunky and inefficient method.

Additionally, for large degrees of freedom (50,000 or so) I can't even calculate the chi-squared CDF because the values are too high. I noticed that this function can be expressed as a ratio of the gamma function and incomplete gamma function, so It occurred to me to express the value as a difference of logs of each piece. However, I have only found expressions of the incomplete gamma function as sums, which are difficult (impossible?) to log. is there any way to express the incomplete gamma function as a product?

I think the scaled inverse chi square distribution is what you're after. The scaling factor is the population variance. The characteristic function of the incomplete gamma is expressed as a product (as are all characteristic functions). This link may help:

http://jacki.wikidoc.org/index.php/Scale-inverse-chi-square_distribution
 
Last edited by a moderator:
  • #3
well isn't the characteristic function for the incomplete gamma function an integral? which is a sum?

and just to clarify (and I might be wrong here) but I am not talking about the inverse chi-squared distribution, I am talking about the inverse function for the chi-squared function.
 
  • #4
To invert the gamma cdf, two different approaches are described in the documentation for gaminv in MATLAB and qgamma in R.
 
  • #5
in MATLAB, they just numerically solve the integral, however, with large degrees of freedom (50,000 or so) the program will crash because the values are just too large.
I guess this question is better suited for a programming board, and directed at larger number data types rather than better mathematical methods.
 
  • #6
If you just want the quantile (inverse CDF) of the chi squared distribution, that can be approximated with the normal distribution inverse CDF for large numbers of degrees of freedom.

That isn't known analytically either, but MATLAB etc. have good approximations.

Or do you want something else? I have to admit I'm having trouble relating this to your question about the characteristic fn of a gamma function.
 
  • #7
onanox said:
in MATLAB, they just numerically solve the integral, however, with large degrees of freedom (50,000 or so) the program will crash because the values are just too large.
I guess this question is better suited for a programming board, and directed at larger number data types rather than better mathematical methods.

MATLAB has no problems with large dof, e.g.

>>chi2inv(0.75,1e6) % returns 1.001e6
 
  • #8
I meant, matlab's documentation does not give any real info except that they solve it numerically, yet when I try to use a similar method in AS3, the program errors on high values.
I apologize for my ambiguity.
 
  • #10
Here are the references for GAMMAINCINV which inverts the regularized incomplete gamma function (i.e. the gamma cdf with scale parameter 1) using Newton's method:

% References:
% [1] Abramowitz & Stegun, Handbook of Mathematical Functions,
% Sec. 6.5, especially 6.5.29 and 26.5.31.
% [2] Knuesel, L. (1986) "Computation of the Chi-square and Poisson
% Distribution", SIAM J. Sci. Stat. Comput., 7(3):1022-1036.

For the Newton iterations, to compute the derivative of gammainc (the gamma pdf) you should use exp(gammaln(...)*...) to avoid underflow/overflow.
 
  • #12
onanox said:
Q(xp)=1-P(xp)=p
any idea what this means?
especially noting that
Q(x2p | v) = p

I don't know what Q is. I think [itex] P(x_p) [/itex] is probably the cumulative distribution of the chi-square as defined on page 262.

In browsing the online book, I notice that the bottom of some of the pages are cut off, such as page 936. I wonder if that's worth reporting to someone, or does everybody already know that? I have a hard copy of this book packed away somewhere.

A more modern reference is the Digital Library Of Mathematical Functions. They define a P and Q on this page: http://dlmf.nist.gov/8

The bad thing about this reference is that they have little explanation of how their special functions are used in probabiity theory.

I notice the Wikipedia article on the inverse chi-square ( http://en.wikipedia.org/wiki/Inverse-chi-square_distribution) says there are two different distributions by that name. Do we have the one you want?
 
  • #13
once again, I am NOT looking for an "inverse chi squared" distribution (which is really a reciprocal chi squared distribution)
I am looking for an inverse function for the chi squared distribution.after reading that link, it becomes apparent that the chi squared CDF is equivalent to the normalized incomplete gamma function.
the GNU Scientific Library defines a function for that, so I am currently checking that documentation.
 
Last edited:

FAQ: Chi-squared inverse function and incomplete gamma function

1. What is the Chi-squared inverse function?

The Chi-squared inverse function, also known as the inverse chi-square cumulative distribution function, is a mathematical function that calculates the value of a chi-squared distribution given a specific probability. It is the inverse of the chi-squared cumulative distribution function and is commonly used in statistical analysis.

2. How is the Chi-squared inverse function calculated?

The Chi-squared inverse function is typically calculated using numerical methods, such as the Newton-Raphson method or the bisection method. These methods involve repeatedly estimating the value of the function until the desired level of accuracy is achieved. Advanced software packages, such as MATLAB or R, also have built-in functions for calculating the Chi-squared inverse function.

3. What is the Incomplete Gamma function?

The Incomplete Gamma function is a mathematical function that is used to calculate the cumulative distribution function of the gamma distribution. It is defined as the integral of the gamma probability density function from 0 to x. The Incomplete Gamma function is closely related to the Chi-squared distribution, as it is the distribution of the sum of squared standard normal random variables.

4. How is the Incomplete Gamma function related to the Chi-squared inverse function?

The Chi-squared inverse function and the Incomplete Gamma function are closely related, as the Chi-squared distribution can be expressed in terms of the Incomplete Gamma function. Specifically, the Chi-squared inverse function is equal to the inverse of the Incomplete Gamma function evaluated at a certain probability. This relationship is useful in statistical analysis involving the Chi-squared distribution.

5. What are the applications of the Chi-squared inverse function and the Incomplete Gamma function?

The Chi-squared inverse function and the Incomplete Gamma function are commonly used in statistical analysis, particularly in hypothesis testing and confidence interval calculations. They are also used in a variety of fields, such as physics, engineering, and economics, to model and analyze data. Additionally, these functions are important in understanding the properties of the Chi-squared distribution, which has many applications in statistical modeling and data analysis.

Similar threads

Replies
4
Views
4K
Replies
20
Views
3K
Replies
2
Views
2K
Replies
6
Views
21K
Replies
10
Views
1K
Replies
14
Views
2K
Back
Top