ugamma: The Unit Gamma Distribution

ugammaR Documentation

The Unit Gamma Distribution

Description

Density, distribution function, quantile function, and random generation for the unit gamma distribution parameterized in terms of mean (mu) and dispersion sigma parameters.

Usage

dugamma(x, mu, sigma, log.p = FALSE)

pugamma(q, mu, sigma, lower.tail = TRUE)

qugamma(p, mu, sigma, lower.tail = TRUE)

rugamma(n, mu, sigma)

Arguments

x, q

vector of quantiles.

mu

vector of means, taking values on (0, 1).

sigma

vector of dispersion parameters, taking values on (0, 1).

log.p

logical; if TRUE, probabilities p are given as log(p).

lower.tail

logical; if TRUE (default), probabilities are P(X <= x), otherwise, P(X > x).

p

vector of probabilities.

n

number of random values to return.

Details

A continuous random variable Y is said to follow a unit gamma distribution with mean \mu and dispersion parameter \sigma if its probability density function is given by

f(y; \mu,\sigma) = \dfrac{y^{d(\mu,\sigma) - 1} d(\mu,\sigma)^{1/\sigma^2-1}}{\Gamma\left(\dfrac{1}{\sigma^2}-1\right)}\left\{\log \left(\frac{1}{y}\right) \right\}^{1/\sigma^2-2}, \quad y \in (0, 1),

where

d(\mu,\sigma)=\frac{\mu^{\sigma^2/(1-\sigma^2)}}{1-\mu^{\sigma^2/(1-\sigma^2)}},

for \mu, \sigma \in (0, 1).

Value

dugamma returns the probability function, pugamma gives the distribution function, qugamma gives the quantile function, and rugamma generates random observations.

Author(s)

Rodrigo M. R. de Medeiros <rodrigo.matheus@live.com>

Examples

## Probability density function for some combinations of
## the parameter values
curve(dugamma(x, 0.25, 0.5), col = 1, ylim = c(0, 4), ylab = "Density")
curve(dugamma(x, 0.3, 0.5), col = 2, add = TRUE)
curve(dugamma(x, 0.5, 0.5), col = 3, add = TRUE)
curve(dugamma(x, 0.6, 0.5), col = 4, add = TRUE)
curve(dugamma(x, 0.73, 0.5), col = 6, add = TRUE)
legend("topleft", c(expression(mu == 0.25~","~ sigma==0.5),
                    expression(mu == 0.30~","~ sigma==0.5),
                    expression(mu == 0.50~","~ sigma==0.5)),
       lty = 1, col = 1:3, bty = "n")

legend("top", c(expression(mu == 0.60~","~ sigma==0.5),
                expression(mu == 0.73~","~ sigma==0.5)),
       lty = 1, col = c(4, 6), bty = "n")


## Random generation
y <- rugamma(1000, 0.25, 0.5)

hist(y, prob = TRUE, col = "white")
curve(dugamma(x, 0.25, 0.5), col = "blue", add = TRUE, lwd = 2)

plot(ecdf(y), col = "grey")
curve(pugamma(x, 0.25, 0.5), col = "blue", add = TRUE)

plot(ppoints(1000), quantile(y, probs = ppoints(1000)),
     xlab = "p", ylab = expression(p-"Quantile"), pch = 16, col = "grey")
curve(qugamma(x, 0.25, 0.5), col = "blue", add = TRUE)

rdmatheus/ugrpl documentation built on July 13, 2024, 10:24 p.m.