dgamma.R

0th

Percentile

Gamma Density Function Alternatives

dgamma.R() is aimed to be an R level “clone” of R's C level implementation dgamma (from package stats).

Keywords
distribution, math
Usage
dgamma.R(x, shape, scale = 1, log)
Arguments
x

non-negative numeric vector.

shape

non-negative shape parameter of the Gamma distribution.

scale

positive scale parameter; note we do not see the need to have a rate parameter as the standard R function.

log

logical indicating if the result is desired on the log scale.

Value

numeric vector of the same length as x (which may have to be thought of recycled along shape and/or scale.

See Also

(As R's C code) this depends crucially on the “workhorse” function dpois_raw().

Aliases
  • dgamma.R
Examples
# NOT RUN {
## TODO: ... regular case .. use all.equal() ...


## PR#17577 - dgamma(x, shape)  for shape < 1 (=> +Inf at x=0) and very small x
stopifnot(exprs = {
    all.equal(dgamma.R(2^-1027, shape = .99 , log=TRUE), 7.1127667376, tol=1e-10)
    all.equal(dgamma.R(2^-1031, shape = 1e-2, log=TRUE), 702.8889158,  tol=1e-10)
    all.equal(dgamma.R(2^-1048, shape = 1e-7, log=TRUE), 710.30007699, tol=1e-10)
    all.equal(dgamma.R(2^-1048, shape = 1e-7, scale = 1e-315, log=TRUE),
              709.96858768, tol=1e-10)
})
## R's dgamma() gave all Inf in R <= 3.6.1 [and still there in 32-bit Windows !]
# }
Documentation reproduced from package DPQ, version 0.3-3, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.