Re: Question about Simple Taylor Series
From: David Sexton (da5id65536_at_yahoo.com)
Date: 06/19/04
- Next message: Julian V. Noble: "Re: Recurring Deposits"
- Previous message: Gerry Thomas: "Re: Estimating the condition of an upper triangular matrix"
- In reply to: Ian Smith: "Re: Question about Simple Taylor Series"
- Next in thread: Ian Smith: "Re: Question about Simple Taylor Series"
- Reply: Ian Smith: "Re: Question about Simple Taylor Series"
- Messages sorted by: [ date ] [ thread ]
Date: 19 Jun 2004 12:06:09 -0700
iandjmsmith@aol.com (Ian Smith) wrote in message news:<2dc49b63.0406160429.33d04f21@posting.google.com>...
> da5id65536@yahoo.com (David Sexton) wrote in message news:<1ac1d2b9.0406121254.62860235@posting.google.com>...
> > In the question below, "^" means "to the power of," and "gamma" is the
> > complete gamma function (where, for an integer n, gamma(n+1) = n!).
> >
> > If "a" is an integer, then
> >
> > e - summation{[for n = a to infinity] (x^n)/gamma(n+1)}
> >
> > equals
> >
> > summation{[for n = 0 to a - 1] (x^n)/gamma(n+1)}
> >
> > That's an easy enough problem, even for me. However, the case where
> > "a" is not an integer is not so easy, for me. Could someone please
> > stoop to helping me?
> >
> > In case it matters, I'm trying to create better C code for calculating
> > the standard error function and percentiles corresponding to
> > chi-squared statistics.
> >
> > David Sexton
>
> Your formulae don't look quite right.
>
> The probability density function for the standard gamma distribution
> is exp(-x).x^(a-1)/gamma(a) for x > 0 and a > 0.
>
> The cumulative density function is obtained by integrating the pdf.
> The integral can also be expressed in terms of various summations,
> continued fractions, asymptotic expansions... A&S gives some of these
> formulae in sections 6 & 26 (see
> http://www.convertit.com/Go/Photonicsonline/Reference/AMS55.ASP).
> Which method to use when is the real issue when producing code to
> deliver accurate results.
>
> The chi-squared distribution and the normal distribution can both be
> expressed in terms of the gamma distribution. Personally, I use a
> specialised function to evaluate the cdf of the normal distribution
> and then call this function when evaluating the asymptotic expansion
> for the gamma distribution.
>
> If you want to calculate percentile points then you need to be able to
> invert the cdf. I find the easiest way to solve F(x;a)=p is to use
> simple first guess methods, based on Normal approximations and the
> like, and then solve log(F(x;a))=log(p) using the Newton-Raphson
> method. For small p, the logged equation is usually a much more linear
> equation than the original F(x;a)=p.
>
> You are more than welcome to start from the Javascript code in
> http://members.aol.com/iandjmsmith/myfunctions.js It can be easily
> translated to C - I believe there are even free translators for this
> purpose. The code is mainly intended to deliver accurate answers over
> a wide range of parameters. It is pretty quick, but could definitely
> be made quicker and more compact if that's what you mean by better.
>
> Calculators for the Normal, Chi-squared and the Gamma distributions
> can be found at http://members.aol.com/iandjmsmith/EXAMPLES.HTM The
> calculator examples demonstrate how to call the functions available in
> myfunctions.js and the higher level error-handling required.
>
>
> Ian Smith
Thanks for the reply. The formulae that I am using now are formula 2
on this page
http://mathworld.wolfram.com/IncompleteGammaFunction.html
and formulae 6.2.5 and 6.2.7 on page 217 of
http://www.library.cornell.edu/nr/bookcpdf/c6-2.pdf
I get the most accurate results with the MathWorld formula, but it
only works when "a" (of Gamma(a,x)) is an integer. I was hoping to
find, at least, a similarly accurate formula for all the cases when 2a
is an integer. The Numerical Recipes formulae are fast, but
disappointingly inaccurate when "a" is large. I am willing to trade
quite a bit of speed for accuracy.
The problem with the NM formulae is the necessity of using logs and
antilogs to deal with the very large numbers involved. There's a
simple "trick" for preventing overflow with the MathWorld formula that
I can't use with the NM formulae.
David Sexton
- Next message: Julian V. Noble: "Re: Recurring Deposits"
- Previous message: Gerry Thomas: "Re: Estimating the condition of an upper triangular matrix"
- In reply to: Ian Smith: "Re: Question about Simple Taylor Series"
- Next in thread: Ian Smith: "Re: Question about Simple Taylor Series"
- Reply: Ian Smith: "Re: Question about Simple Taylor Series"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|