[R] Regularized gamma function/ incomplete gamma function
Ravi Varadhan
RVaradhan at jhmi.edu
Sat Dec 12 00:49:02 CET 2009
You can do this using the package "numDeriv".
require(zipfR)
require(numDeriv)
fn <- function(x, y) Rgamma.inv(x, y)
gRgamma.inv <- function(y, k) sapply(y, function(y) grad(x=k, func=fn, y=y))
plot(gRgamma.inv(y=seq(0,1, length=200), k=1), type="l", xlab="x",
ylab="Derivative of Rgamma.inv w.r.t. `k' ")
lines(gRgamma.inv(seq(0,1, length=200), k=2), col=2)
lines(gRgamma.inv(seq(0,1, length=200), k=5), col=3)
lines(gRgamma.inv(seq(0,1, length=200), k=10), col=4)
I hope this helps,
Ravi.
----------------------------------------------------------------------------
-------
Ravi Varadhan, Ph.D.
Assistant Professor, The Center on Aging and Health
Division of Geriatric Medicine and Gerontology
Johns Hopkins University
Ph: (410) 502-2619
Fax: (410) 614-9625
Email: rvaradhan at jhmi.edu
Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml
----------------------------------------------------------------------------
--------
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of A.Noufaily
Sent: Friday, December 11, 2009 11:13 AM
To: r-help at R-project.org
Subject: [R] Regularized gamma function/ incomplete gamma function
Dear all,
I would be very grateful if you could help me with:
Given the regularized gamma function Reg=int_0^r (x^(k-1)e^(-x))dx/int_0^Inf
(x^(k-1)e^(-x))dx ; 0<r<Inf (which is eventually the ratio of the
Incomplete gamma function by the gamma function), does anyone know of a
package in R that would evaluate the derivative of the inverse of Reg with
respect to k? I am aware that the function "Rgamma.inv" of the package
"Zipfr" evaluates the inverse
of Reg and I'm wondering wether there is a function that would evaluate the
derivative of the inverse..
Alternatively, a good numerical integration package/ or simply a function
that could evaluate the integral int_0^r (log(x) x^(k-1) e^(-x))dx; 0<r<Inf
would be useful. I tried the function "int" of the package "rmutil" but I'm
not sure wether it is accurate especially for small values of k. Does R have
a powerful numerical integration package that can deal with such functions
especially when the limit close to zero in + or - Inf?
Many thanks for this opportunity to post our queries,
Amy
________________________________
The Open University is incorporated by Royal Charter (RC 000391), an exempt
charity in England & Wales and a charity registered in Scotland (SC 038302).
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list