gamma {distributionsrd}R Documentation

The Gamma distribution

Description

Raw moments for the Gamma distribution.

Usage

mgamma(
  r = 0,
  truncation = 0,
  shape = 2,
  rate = 1,
  scale = 1/rate,
  lower.tail = TRUE
)

Arguments

r

rth raw moment of the distribution, defaults to 1.

truncation

lower truncation parameter, defaults to 0.

shape, rate, scale

shape, rate and scale of the distribution with default values of 2 and 1 respectively.

lower.tail

logical; if TRUE (default), moments are E[x^r|X ≤ y], otherwise, E[x^r|X > y]

Details

Probability and Cumulative Distribution Function:

f(x) = \frac{1}{s^kΓ(k)}ω^{k-1}e^{-\frac{ω}{s}},\qquad F_X(x) = \frac{1}{Γ(k)}γ(k,\frac{ω}{s})

,

where Γ(x) stands for the upper incomplete gamma function function, while γ(s,x) stands for the lower incomplete Gamma function with upper bound x.

The y-bounded r-th raw moment of the distribution equals:

μ^r_y = \frac{s^{r}}{Γ(k)} Γ≤ft(r + k , \frac{y}{s} \right)

Value

Provides the truncated rth raw moment of the distribution.

## The zeroth truncated moment is equivalent to the probability function pgamma(2,shape=2,rate=1) mgamma(truncation=2)

## The (truncated) first moment is equivalent to the mean of a (truncated) random sample, #for large enough samples. x = rgamma(1e5,shape=2,rate=1) mean(x) mgamma(r=1,lower.tail=FALSE)

sum(x[x>quantile(x,0.1)])/length(x) mgamma(r=1,truncation=quantile(x,0.1),lower.tail=FALSE)


[Package distributionsrd version 0.0.6 Index]