Hello I am trying to evaluate an Incomplete gamma function in R. Library Zipfr gives the Igamma function. From Mathematica, I have: "Gamma[a, z] is the incomplete gamma function." In[16]: Gamma[9,11.1] Out[16]: 9000.5 Trying the same in R, I get> Igamma(9,11.1)[1] 31319.5 OR> Igamma(11.1,9)[1] 1300998 I know I have to understand the theory and the math behind it rather than just ask for help, but while I am trying to do that (and only taking baby steps, I must admit), I was hoping someone could help me out. Regard Kris. ____________________________________________________________________________________ Got a little couch potato? Check out fun summer activities for kids.
Hi Kris lgamma() gives the log of the gamma function. You need gamma_inc() of the gsl package, a wrapper for the GSL library: > gamma_inc(9,11.1) [1] 9000.501 > HTH rksh On 31 Aug 2007, at 00:29, poolloopus at yahoo.com wrote:> Hello > > I am trying to evaluate an Incomplete gamma function > in R. Library Zipfr gives the Igamma function. From > Mathematica, I have: > > "Gamma[a, z] is the incomplete gamma function." > > In[16]: Gamma[9,11.1] > Out[16]: 9000.5 > > Trying the same in R, I get > >> Igamma(9,11.1) > [1] 31319.5 > OR >> Igamma(11.1,9) > [1] 1300998 > > I know I have to understand the theory and the math > behind it rather than just ask for help, but while I > am trying to do that (and only taking baby steps, I > must admit), I was hoping someone could help me out. > > Regard > > Kris. > > > > ______________________________________________________________________ > ______________ > Got a little couch potato? > Check out fun summer activities for kids. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code.-- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743
Hi Kris, You just need to understand the mathematics of the incomplete gamma function and the various relationships it has. The answers from both Mathematica and R are correct, except that they are giving you different estimated quantities. It depends on the way the gamma function is written. For instance in R to get the equivalent result from mathematica you should do the following answer <- gamma(9) - Igamma(9,11.1). This will give you the incomplete gamma for (9,11.1) as given by Mathematica. You can read more about the model and am sure you will figure it out. Regards Anup --------------------------------- Got a little couch potato? Check out fun summer activities for kids. [[alternative HTML version deleted]]