[R] a function to compute the cumulative distribution function (cdf) of the gamma
bolker at ufl.edu
Mon Oct 8 13:52:28 CEST 2007
elodie gillain wrote:
> Dear Forum,
> I would need to write a function to calculate the cumulative distribution
> function (cdf) of the gamma random variable. I am allowed to use the
> following precoded functions: rgamma, pgamma, and dgamma. I am a little
> overwhelmed by this project, I am wondering how I should start. Should I
> sum dgamma (or pgamma) from 0 to x, in order to obtain the cdf at x?
This is a little bit confusing since pgamma() *is* the cumulative
distribution function of a gamma random variable. (Also, "allowed
to use" makes this sound a little like a homework problem ...)
If you really wanted to do things the hard, inefficient way, you
could use integrate() to numerically integrate (not sum) dgamma()
from 0 to x -- but why not use pgamma() ??
View this message in context: http://www.nabble.com/a-function-to-compute-the-cumulative-distribution-function-%28cdf%29-of-the-gamma-tf4581664.html#a13095089
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help