Title: | Additional Univariate and Multivariate Distributions |
---|---|
Description: | Density, distribution function, quantile function and random generation for a number of univariate and multivariate distributions. This package implements the following distributions: Bernoulli, beta-binomial, beta-negative binomial, beta prime, Bhattacharjee, Birnbaum-Saunders, bivariate normal, bivariate Poisson, categorical, Dirichlet, Dirichlet-multinomial, discrete gamma, discrete Laplace, discrete normal, discrete uniform, discrete Weibull, Frechet, gamma-Poisson, generalized extreme value, Gompertz, generalized Pareto, Gumbel, half-Cauchy, half-normal, half-t, Huber density, inverse chi-squared, inverse-gamma, Kumaraswamy, Laplace, location-scale t, logarithmic, Lomax, multivariate hypergeometric, multinomial, negative hypergeometric, non-standard beta, normal mixture, Poisson mixture, Pareto, power, reparametrized beta, Rayleigh, shifted Gompertz, Skellam, slash, triangular, truncated binomial, truncated normal, truncated Poisson, Tukey lambda, Wald, zero-inflated binomial, zero-inflated negative binomial, zero-inflated Poisson. |
Authors: | Tymoteusz Wolodzko |
Maintainer: | Tymoteusz Wolodzko <[email protected]> |
License: | GPL-2 |
Version: | 1.10.0 |
Built: | 2024-11-09 05:53:21 UTC |
Source: | https://github.com/twolodzko/extradistr |
Probability mass function, distribution function, quantile function and random generation for the Bernoulli distribution.
dbern(x, prob = 0.5, log = FALSE) pbern(q, prob = 0.5, lower.tail = TRUE, log.p = FALSE) qbern(p, prob = 0.5, lower.tail = TRUE, log.p = FALSE) rbern(n, prob = 0.5)
dbern(x, prob = 0.5, log = FALSE) pbern(q, prob = 0.5, lower.tail = TRUE, log.p = FALSE) qbern(p, prob = 0.5, lower.tail = TRUE, log.p = FALSE) rbern(n, prob = 0.5)
x , q
|
vector of quantiles. |
prob |
probability of success; ( |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
prop.table(table(rbern(1e5, 0.5)))
prop.table(table(rbern(1e5, 0.5)))
Probability mass function and random generation for the beta-binomial distribution.
dbbinom(x, size, alpha = 1, beta = 1, log = FALSE) pbbinom(q, size, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE) rbbinom(n, size, alpha = 1, beta = 1)
dbbinom(x, size, alpha = 1, beta = 1, log = FALSE) pbbinom(q, size, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE) rbbinom(n, size, alpha = 1, beta = 1)
x , q
|
vector of quantiles. |
size |
number of trials (zero or more). |
alpha , beta
|
non-negative parameters of the beta distribution. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
If and
, then
.
Probability mass function
Cumulative distribution function is calculated using recursive algorithm that employs the fact that
, and
, and that
. This enables re-writing probability mass function as
what makes recursive updating from to
easy using the properties of factorials
and let's us efficiently calculate cumulative distribution function as a sum of probability mass functions
x <- rbbinom(1e5, 1000, 5, 13) xx <- 0:1000 hist(x, 100, freq = FALSE) lines(xx-0.5, dbbinom(xx, 1000, 5, 13), col = "red") hist(pbbinom(x, 1000, 5, 13)) xx <- seq(0, 1000, by = 0.1) plot(ecdf(x)) lines(xx, pbbinom(xx, 1000, 5, 13), col = "red", lwd = 2)
x <- rbbinom(1e5, 1000, 5, 13) xx <- 0:1000 hist(x, 100, freq = FALSE) lines(xx-0.5, dbbinom(xx, 1000, 5, 13), col = "red") hist(pbbinom(x, 1000, 5, 13)) xx <- seq(0, 1000, by = 0.1) plot(ecdf(x)) lines(xx, pbbinom(xx, 1000, 5, 13), col = "red", lwd = 2)
Probability mass function and random generation for the beta-negative binomial distribution.
dbnbinom(x, size, alpha = 1, beta = 1, log = FALSE) pbnbinom(q, size, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE) rbnbinom(n, size, alpha = 1, beta = 1)
dbnbinom(x, size, alpha = 1, beta = 1, log = FALSE) pbnbinom(q, size, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE) rbnbinom(n, size, alpha = 1, beta = 1)
x , q
|
vector of quantiles. |
size |
number of trials (zero or more). Must be strictly positive, need not be integer. |
alpha , beta
|
non-negative parameters of the beta distribution. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
If and
, then
.
Probability mass function
Cumulative distribution function is calculated using recursive algorithm that employs the fact that
and
. This enables re-writing probability mass function as
what makes recursive updating from to
easy using the properties of factorials
and let's us efficiently calculate cumulative distribution function as a sum of probability mass functions
x <- rbnbinom(1e5, 1000, 5, 13) xx <- 0:1e5 hist(x, 100, freq = FALSE) lines(xx-0.5, dbnbinom(xx, 1000, 5, 13), col = "red") hist(pbnbinom(x, 1000, 5, 13)) xx <- seq(0, 1e5, by = 0.1) plot(ecdf(x)) lines(xx, pbnbinom(xx, 1000, 5, 13), col = "red", lwd = 2)
x <- rbnbinom(1e5, 1000, 5, 13) xx <- 0:1e5 hist(x, 100, freq = FALSE) lines(xx-0.5, dbnbinom(xx, 1000, 5, 13), col = "red") hist(pbnbinom(x, 1000, 5, 13)) xx <- seq(0, 1e5, by = 0.1) plot(ecdf(x)) lines(xx, pbnbinom(xx, 1000, 5, 13), col = "red", lwd = 2)
Density, distribution function, quantile function and random generation for the beta prime distribution.
dbetapr(x, shape1, shape2, scale = 1, log = FALSE) pbetapr(q, shape1, shape2, scale = 1, lower.tail = TRUE, log.p = FALSE) qbetapr(p, shape1, shape2, scale = 1, lower.tail = TRUE, log.p = FALSE) rbetapr(n, shape1, shape2, scale = 1)
dbetapr(x, shape1, shape2, scale = 1, log = FALSE) pbetapr(q, shape1, shape2, scale = 1, lower.tail = TRUE, log.p = FALSE) qbetapr(p, shape1, shape2, scale = 1, lower.tail = TRUE, log.p = FALSE) rbetapr(n, shape1, shape2, scale = 1)
x , q
|
vector of quantiles. |
shape1 , shape2
|
non-negative parameters. |
scale |
positive valued scale parameter. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
If , then
.
Probability density function
Cumulative distribution function
x <- rbetapr(1e5, 5, 3, 2) hist(x, 350, freq = FALSE, xlim = c(0, 100)) curve(dbetapr(x, 5, 3, 2), 0, 100, col = "red", add = TRUE, n = 500) hist(pbetapr(x, 5, 3, 2)) plot(ecdf(x), xlim = c(0, 100)) curve(pbetapr(x, 5, 3, 2), 0, 100, col = "red", add = TRUE, n = 500)
x <- rbetapr(1e5, 5, 3, 2) hist(x, 350, freq = FALSE, xlim = c(0, 100)) curve(dbetapr(x, 5, 3, 2), 0, 100, col = "red", add = TRUE, n = 500) hist(pbetapr(x, 5, 3, 2)) plot(ecdf(x), xlim = c(0, 100)) curve(pbetapr(x, 5, 3, 2), 0, 100, col = "red", add = TRUE, n = 500)
Density, distribution function, and random generation for the Bhattacharjee distribution.
dbhatt(x, mu = 0, sigma = 1, a = sigma, log = FALSE) pbhatt(q, mu = 0, sigma = 1, a = sigma, lower.tail = TRUE, log.p = FALSE) rbhatt(n, mu = 0, sigma = 1, a = sigma)
dbhatt(x, mu = 0, sigma = 1, a = sigma, log = FALSE) pbhatt(q, mu = 0, sigma = 1, a = sigma, lower.tail = TRUE, log.p = FALSE) rbhatt(n, mu = 0, sigma = 1, a = sigma)
x , q
|
vector of quantiles. |
mu , sigma , a
|
location, scale and shape parameters. Scale and shape must be positive. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
If and
, then
follows Bhattacharjee distribution.
Probability density function
Cumulative distribution function
Bhattacharjee, G.P., Pandit, S.N.N., and Mohan, R. (1963). Dimensional chains involving rectangular and normal error-distributions. Technometrics, 5, 404-406.
x <- rbhatt(1e5, 5, 3, 5) hist(x, 100, freq = FALSE) curve(dbhatt(x, 5, 3, 5), -20, 20, col = "red", add = TRUE) hist(pbhatt(x, 5, 3, 5)) plot(ecdf(x)) curve(pbhatt(x, 5, 3, 5), -20, 20, col = "red", lwd = 2, add = TRUE)
x <- rbhatt(1e5, 5, 3, 5) hist(x, 100, freq = FALSE) curve(dbhatt(x, 5, 3, 5), -20, 20, col = "red", add = TRUE) hist(pbhatt(x, 5, 3, 5)) plot(ecdf(x)) curve(pbhatt(x, 5, 3, 5), -20, 20, col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the Birnbaum-Saunders (fatigue life) distribution.
dfatigue(x, alpha, beta = 1, mu = 0, log = FALSE) pfatigue(q, alpha, beta = 1, mu = 0, lower.tail = TRUE, log.p = FALSE) qfatigue(p, alpha, beta = 1, mu = 0, lower.tail = TRUE, log.p = FALSE) rfatigue(n, alpha, beta = 1, mu = 0)
dfatigue(x, alpha, beta = 1, mu = 0, log = FALSE) pfatigue(q, alpha, beta = 1, mu = 0, lower.tail = TRUE, log.p = FALSE) qfatigue(p, alpha, beta = 1, mu = 0, lower.tail = TRUE, log.p = FALSE) rfatigue(n, alpha, beta = 1, mu = 0)
x , q
|
vector of quantiles. |
alpha , beta , mu
|
shape, scale and location parameters. Scale and shape must be positive. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
Birnbaum, Z. W. and Saunders, S. C. (1969). A new family of life distributions. Journal of Applied Probability, 6(2), 637-652.
Desmond, A. (1985) Stochastic models of failure in random environments. Canadian Journal of Statistics, 13, 171-183.
Vilca-Labra, F., and Leiva-Sanchez, V. (2006). A new fatigue life model based on the family of skew-elliptical distributions. Communications in Statistics-Theory and Methods, 35(2), 229-244.
Leiva, V., Sanhueza, A., Sen, P. K., and Paula, G. A. (2008). Random number generators for the generalized Birnbaum-Saunders distribution. Journal of Statistical Computation and Simulation, 78(11), 1105-1118.
x <- rfatigue(1e5, .5, 2, 5) hist(x, 100, freq = FALSE) curve(dfatigue(x, .5, 2, 5), 2, 20, col = "red", add = TRUE) hist(pfatigue(x, .5, 2, 5)) plot(ecdf(x)) curve(pfatigue(x, .5, 2, 5), 2, 20, col = "red", lwd = 2, add = TRUE)
x <- rfatigue(1e5, .5, 2, 5) hist(x, 100, freq = FALSE) curve(dfatigue(x, .5, 2, 5), 2, 20, col = "red", add = TRUE) hist(pfatigue(x, .5, 2, 5)) plot(ecdf(x)) curve(pfatigue(x, .5, 2, 5), 2, 20, col = "red", lwd = 2, add = TRUE)
Density, distribution function and random generation for the bivariate normal distribution.
dbvnorm( x, y = NULL, mean1 = 0, mean2 = mean1, sd1 = 1, sd2 = sd1, cor = 0, log = FALSE ) rbvnorm(n, mean1 = 0, mean2 = mean1, sd1 = 1, sd2 = sd1, cor = 0)
dbvnorm( x, y = NULL, mean1 = 0, mean2 = mean1, sd1 = 1, sd2 = sd1, cor = 0, log = FALSE ) rbvnorm(n, mean1 = 0, mean2 = mean1, sd1 = 1, sd2 = sd1, cor = 0)
x , y
|
vectors of quantiles; alternatively x may be a two-column matrix (or data.frame) and y may be omitted. |
mean1 , mean2
|
vectors of means. |
sd1 , sd2
|
vectors of standard deviations. |
cor |
vector of correlations ( |
log |
logical; if TRUE, probabilities p are given as log(p). |
n |
number of observations. If |
Probability density function
Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications. Chapman & Hall/CRC
Mukhopadhyay, N. (2000). Probability and statistical inference. Chapman & Hall/CRC
y <- x <- seq(-4, 4, by = 0.25) z <- outer(x, y, function(x, y) dbvnorm(x, y, cor = -0.75)) persp(x, y, z) y <- x <- seq(-4, 4, by = 0.25) z <- outer(x, y, function(x, y) dbvnorm(x, y, cor = -0.25)) persp(x, y, z)
y <- x <- seq(-4, 4, by = 0.25) z <- outer(x, y, function(x, y) dbvnorm(x, y, cor = -0.75)) persp(x, y, z) y <- x <- seq(-4, 4, by = 0.25) z <- outer(x, y, function(x, y) dbvnorm(x, y, cor = -0.25)) persp(x, y, z)
Probability mass function and random generation for the bivariate Poisson distribution.
dbvpois(x, y = NULL, a, b, c, log = FALSE) rbvpois(n, a, b, c)
dbvpois(x, y = NULL, a, b, c, log = FALSE) rbvpois(n, a, b, c)
x , y
|
vectors of quantiles; alternatively x may be a two-column matrix (or data.frame) and y may be omitted. |
a , b , c
|
positive valued parameters. |
log |
logical; if TRUE, probabilities p are given as log(p). |
n |
number of observations. If |
Probability mass function
Karlis, D. and Ntzoufras, I. (2003). Analysis of sports data by using bivariate Poisson models. Journal of the Royal Statistical Society: Series D (The Statistician), 52(3), 381-393.
Kocherlakota, S. and Kocherlakota, K. (1992) Bivariate Discrete Distributions. New York: Dekker.
Johnson, N., Kotz, S. and Balakrishnan, N. (1997). Discrete Multivariate Distributions. New York: Wiley.
Holgate, P. (1964). Estimation for the bivariate Poisson distribution. Biometrika, 51(1-2), 241-287.
Kawamura, K. (1984). Direct calculation of maximum likelihood estimator for the bivariate Poisson distribution. Kodai mathematical journal, 7(2), 211-221.
x <- rbvpois(5000, 7, 8, 5) image(prop.table(table(x[,1], x[,2]))) colMeans(x)
x <- rbvpois(5000, 7, 8, 5) image(prop.table(table(x[,1], x[,2]))) colMeans(x)
Probability mass function, distribution function, quantile function and random generation for the categorical distribution.
dcat(x, prob, log = FALSE) pcat(q, prob, lower.tail = TRUE, log.p = FALSE) qcat(p, prob, lower.tail = TRUE, log.p = FALSE, labels) rcat(n, prob, labels) rcatlp(n, log_prob, labels)
dcat(x, prob, log = FALSE) pcat(q, prob, lower.tail = TRUE, log.p = FALSE) qcat(p, prob, lower.tail = TRUE, log.p = FALSE, labels) rcat(n, prob, labels) rcatlp(n, log_prob, labels)
x , q
|
vector of quantiles. |
prob , log_prob
|
vector of length |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
labels |
if provided, labeled |
n |
number of observations. If |
Probability mass function
Cumulative distribution function
It is possible to sample from categorical distribution parametrized
by vector of unnormalized log-probabilities
without leaving the log space by employing the Gumbel-max trick (Maddison, Tarlow and Minka, 2014).
If
are samples from Gumbel distribution with
cumulative distribution function
,
then
is a draw from categorical distribution parametrized by
vector of probabilities
, such that
.
This is implemented in
rcatlp
function parametrized by vector of
log-probabilities log_prob
.
Maddison, C. J., Tarlow, D., & Minka, T. (2014). A* sampling. [In:] Advances in Neural Information Processing Systems (pp. 3086-3094). https://arxiv.org/abs/1411.0030
# Generating 10 random draws from categorical distribution # with k=3 categories occuring with equal probabilities # parametrized using a vector rcat(10, c(1/3, 1/3, 1/3)) # or with k=5 categories parametrized using a matrix of probabilities # (generated from Dirichlet distribution) p <- rdirichlet(10, c(1, 1, 1, 1, 1)) rcat(10, p) x <- rcat(1e5, c(0.2, 0.4, 0.3, 0.1)) plot(prop.table(table(x)), type = "h") lines(0:5, dcat(0:5, c(0.2, 0.4, 0.3, 0.1)), col = "red") p <- rdirichlet(1, rep(1, 20)) x <- rcat(1e5, matrix(rep(p, 2), nrow = 2, byrow = TRUE)) xx <- 0:21 plot(prop.table(table(x))) lines(xx, dcat(xx, p), col = "red") xx <- seq(0, 21, by = 0.01) plot(ecdf(x)) lines(xx, pcat(xx, p), col = "red", lwd = 2) pp <- seq(0, 1, by = 0.001) plot(ecdf(x)) lines(qcat(pp, p), pp, col = "red", lwd = 2)
# Generating 10 random draws from categorical distribution # with k=3 categories occuring with equal probabilities # parametrized using a vector rcat(10, c(1/3, 1/3, 1/3)) # or with k=5 categories parametrized using a matrix of probabilities # (generated from Dirichlet distribution) p <- rdirichlet(10, c(1, 1, 1, 1, 1)) rcat(10, p) x <- rcat(1e5, c(0.2, 0.4, 0.3, 0.1)) plot(prop.table(table(x)), type = "h") lines(0:5, dcat(0:5, c(0.2, 0.4, 0.3, 0.1)), col = "red") p <- rdirichlet(1, rep(1, 20)) x <- rcat(1e5, matrix(rep(p, 2), nrow = 2, byrow = TRUE)) xx <- 0:21 plot(prop.table(table(x))) lines(xx, dcat(xx, p), col = "red") xx <- seq(0, 21, by = 0.01) plot(ecdf(x)) lines(xx, pcat(xx, p), col = "red", lwd = 2) pp <- seq(0, 1, by = 0.001) plot(ecdf(x)) lines(qcat(pp, p), pp, col = "red", lwd = 2)
Density function, cumulative distribution function and random generation for the Dirichlet distribution.
ddirichlet(x, alpha, log = FALSE) rdirichlet(n, alpha)
ddirichlet(x, alpha, log = FALSE) rdirichlet(n, alpha)
x |
|
alpha |
|
log |
logical; if TRUE, probabilities p are given as log(p). |
n |
number of observations. If |
Probability density function
Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag.
# Generating 10 random draws from Dirichlet distribution # parametrized using a vector rdirichlet(10, c(1, 1, 1, 1)) # or parametrized using a matrix where each row # is a vector of parameters alpha <- matrix(c(1, 1, 1, 1:3, 7:9), ncol = 3, byrow = TRUE) rdirichlet(10, alpha)
# Generating 10 random draws from Dirichlet distribution # parametrized using a vector rdirichlet(10, c(1, 1, 1, 1)) # or parametrized using a matrix where each row # is a vector of parameters alpha <- matrix(c(1, 1, 1, 1:3, 7:9), ncol = 3, byrow = TRUE) rdirichlet(10, alpha)
Density function, cumulative distribution function and random generation for the Dirichlet-multinomial (multivariate Polya) distribution.
ddirmnom(x, size, alpha, log = FALSE) rdirmnom(n, size, alpha)
ddirmnom(x, size, alpha, log = FALSE) rdirmnom(n, size, alpha)
x |
|
size |
numeric vector; number of trials (zero or more). |
alpha |
|
log |
logical; if TRUE, probabilities p are given as log(p). |
n |
number of observations. If |
If and
, then
.
Probability density function
Gentle, J.E. (2006). Random number generation and Monte Carlo methods. Springer.
Kvam, P. and Day, D. (2001) The multivariate Polya distribution in combat modeling. Naval Research Logistics, 48, 1-17.
Probability mass function, distribution function and random generation for discrete gamma distribution.
ddgamma(x, shape, rate = 1, scale = 1/rate, log = FALSE) pdgamma(q, shape, rate = 1, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) rdgamma(n, shape, rate = 1, scale = 1/rate)
ddgamma(x, shape, rate = 1, scale = 1/rate, log = FALSE) pdgamma(q, shape, rate = 1, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) rdgamma(n, shape, rate = 1, scale = 1/rate)
x , q
|
vector of quantiles. |
shape , scale
|
shape and scale parameters. Must be positive, scale strictly. |
rate |
an alternative way to specify the scale. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
Probability mass function of discrete gamma distribution
is defined by discretization of continuous gamma distribution
where
is a survival function of continuous gamma distribution.
Chakraborty, S. and Chakravarty, D. (2012). Discrete Gamma distributions: Properties and parameter estimations. Communications in Statistics-Theory and Methods, 41(18), 3301-3324.
x <- rdgamma(1e5, 9, 1) xx <- 0:50 plot(prop.table(table(x))) lines(xx, ddgamma(xx, 9, 1), col = "red") hist(pdgamma(x, 9, 1)) plot(ecdf(x)) xx <- seq(0, 50, 0.1) lines(xx, pdgamma(xx, 9, 1), col = "red", lwd = 2, type = "s")
x <- rdgamma(1e5, 9, 1) xx <- 0:50 plot(prop.table(table(x))) lines(xx, ddgamma(xx, 9, 1), col = "red") hist(pdgamma(x, 9, 1)) plot(ecdf(x)) xx <- seq(0, 50, 0.1) lines(xx, pdgamma(xx, 9, 1), col = "red", lwd = 2, type = "s")
Probability mass, distribution function and random generation for the discrete Laplace distribution parametrized by location and scale.
ddlaplace(x, location, scale, log = FALSE) pdlaplace(q, location, scale, lower.tail = TRUE, log.p = FALSE) rdlaplace(n, location, scale)
ddlaplace(x, location, scale, log = FALSE) pdlaplace(q, location, scale, lower.tail = TRUE, log.p = FALSE) rdlaplace(n, location, scale)
x , q
|
vector of quantiles. |
location |
location parameter. |
scale |
scale parameter; |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
If and
,
then
,
where geometric distribution is related to discrete Laplace distribution
in similar way as exponential distribution is related to Laplace distribution.
Probability mass function
Cumulative distribution function
Inusah, S., & Kozubowski, T.J. (2006). A discrete analogue of the Laplace distribution. Journal of statistical planning and inference, 136(3), 1090-1102.
Kotz, S., Kozubowski, T., & Podgorski, K. (2012). The Laplace distribution and generalizations: a revisit with applications to communications, economics, engineering, and finance. Springer Science & Business Media.
p <- 0.45 x <- rdlaplace(1e5, 0, p) xx <- seq(-200, 200, by = 1) plot(prop.table(table(x))) lines(xx, ddlaplace(xx, 0, p), col = "red") hist(pdlaplace(x, 0, p)) plot(ecdf(x)) lines(xx, pdlaplace(xx, 0, p), col = "red", type = "s")
p <- 0.45 x <- rdlaplace(1e5, 0, p) xx <- seq(-200, 200, by = 1) plot(prop.table(table(x))) lines(xx, ddlaplace(xx, 0, p), col = "red") hist(pdlaplace(x, 0, p)) plot(ecdf(x)) lines(xx, pdlaplace(xx, 0, p), col = "red", type = "s")
Probability mass function, distribution function and random generation for discrete normal distribution.
ddnorm(x, mean = 0, sd = 1, log = FALSE) pdnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) rdnorm(n, mean = 0, sd = 1)
ddnorm(x, mean = 0, sd = 1, log = FALSE) pdnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) rdnorm(n, mean = 0, sd = 1)
x , q
|
vector of quantiles. |
mean |
vector of means. |
sd |
vector of standard deviations. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
Probability mass function
Cumulative distribution function
Roy, D. (2003). The discrete normal distribution. Communications in Statistics-Theory and Methods, 32, 1871-1883.
x <- rdnorm(1e5, 0, 3) xx <- -15:15 plot(prop.table(table(x))) lines(xx, ddnorm(xx, 0, 3), col = "red") hist(pdnorm(x, 0, 3)) plot(ecdf(x)) xx <- seq(-15, 15, 0.1) lines(xx, pdnorm(xx, 0, 3), col = "red", lwd = 2, type = "s")
x <- rdnorm(1e5, 0, 3) xx <- -15:15 plot(prop.table(table(x))) lines(xx, ddnorm(xx, 0, 3), col = "red") hist(pdnorm(x, 0, 3)) plot(ecdf(x)) xx <- seq(-15, 15, 0.1) lines(xx, pdnorm(xx, 0, 3), col = "red", lwd = 2, type = "s")
Probability mass function, distribution function, quantile function and random generation for the discrete uniform distribution.
ddunif(x, min, max, log = FALSE) pdunif(q, min, max, lower.tail = TRUE, log.p = FALSE) qdunif(p, min, max, lower.tail = TRUE, log.p = FALSE) rdunif(n, min, max)
ddunif(x, min, max, log = FALSE) pdunif(q, min, max, lower.tail = TRUE, log.p = FALSE) qdunif(p, min, max, lower.tail = TRUE, log.p = FALSE) rdunif(n, min, max)
x , q
|
vector of quantiles. |
min , max
|
lower and upper limits of the distribution. Must be finite. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
If min == max
, then discrete uniform distribution is a degenerate distribution.
x <- rdunif(1e5, 1, 10) xx <- -1:11 plot(prop.table(table(x)), type = "h") lines(xx, ddunif(xx, 1, 10), col = "red") hist(pdunif(x, 1, 10)) xx <- seq(-1, 11, by = 0.01) plot(ecdf(x)) lines(xx, pdunif(xx, 1, 10), col = "red")
x <- rdunif(1e5, 1, 10) xx <- -1:11 plot(prop.table(table(x)), type = "h") lines(xx, ddunif(xx, 1, 10), col = "red") hist(pdunif(x, 1, 10)) xx <- seq(-1, 11, by = 0.01) plot(ecdf(x)) lines(xx, pdunif(xx, 1, 10), col = "red")
Density, distribution function, quantile function and random generation for the discrete Weibull (type I) distribution.
ddweibull(x, shape1, shape2, log = FALSE) pdweibull(q, shape1, shape2, lower.tail = TRUE, log.p = FALSE) qdweibull(p, shape1, shape2, lower.tail = TRUE, log.p = FALSE) rdweibull(n, shape1, shape2)
ddweibull(x, shape1, shape2, log = FALSE) pdweibull(q, shape1, shape2, lower.tail = TRUE, log.p = FALSE) qdweibull(p, shape1, shape2, lower.tail = TRUE, log.p = FALSE) rdweibull(n, shape1, shape2)
x , q
|
vector of quantiles. |
shape1 , shape2
|
parameters (named q, |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability mass function
Cumulative distribution function
Quantile function
Nakagawa, T. and Osaki, S. (1975). The Discrete Weibull Distribution. IEEE Transactions on Reliability, R-24, 300-301.
Kulasekera, K.B. (1994). Approximate MLE's of the parameters of a discrete Weibull distribution with type I censored data. Microelectronics Reliability, 34(7), 1185-1188.
Khan, M.A., Khalique, A. and Abouammoh, A.M. (1989). On estimating parameters in a discrete Weibull distribution. IEEE Transactions on Reliability, 38(3), 348-350.
x <- rdweibull(1e5, 0.32, 1) xx <- seq(-2, 100, by = 1) plot(prop.table(table(x)), type = "h") lines(xx, ddweibull(xx, .32, 1), col = "red") # Notice: distribution of F(X) is far from uniform: hist(pdweibull(x, .32, 1), 50) plot(ecdf(x)) lines(xx, pdweibull(xx, .32, 1), col = "red", lwd = 2, type = "s")
x <- rdweibull(1e5, 0.32, 1) xx <- seq(-2, 100, by = 1) plot(prop.table(table(x)), type = "h") lines(xx, ddweibull(xx, .32, 1), col = "red") # Notice: distribution of F(X) is far from uniform: hist(pdweibull(x, .32, 1), 50) plot(ecdf(x)) lines(xx, pdweibull(xx, .32, 1), col = "red", lwd = 2, type = "s")
Density, distribution function, quantile function and random generation for the Frechet distribution.
dfrechet(x, lambda = 1, mu = 0, sigma = 1, log = FALSE) pfrechet(q, lambda = 1, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qfrechet(p, lambda = 1, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rfrechet(n, lambda = 1, mu = 0, sigma = 1)
dfrechet(x, lambda = 1, mu = 0, sigma = 1, log = FALSE) pfrechet(q, lambda = 1, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qfrechet(p, lambda = 1, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rfrechet(n, lambda = 1, mu = 0, sigma = 1)
x , q
|
vector of quantiles. |
lambda , sigma , mu
|
shape, scale, and location parameters. Scale and shape must be positive. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
Bury, K. (1999). Statistical Distributions in Engineering. Cambridge University Press.
x <- rfrechet(1e5, 5, 2, 1.5) xx <- seq(0, 1000, by = 0.1) hist(x, 200, freq = FALSE) lines(xx, dfrechet(xx, 5, 2, 1.5), col = "red") hist(pfrechet(x, 5, 2, 1.5)) plot(ecdf(x)) lines(xx, pfrechet(xx, 5, 2, 1.5), col = "red", lwd = 2)
x <- rfrechet(1e5, 5, 2, 1.5) xx <- seq(0, 1000, by = 0.1) hist(x, 200, freq = FALSE) lines(xx, dfrechet(xx, 5, 2, 1.5), col = "red") hist(pfrechet(x, 5, 2, 1.5)) plot(ecdf(x)) lines(xx, pfrechet(xx, 5, 2, 1.5), col = "red", lwd = 2)
Probability mass function and random generation for the gamma-Poisson distribution.
dgpois(x, shape, rate, scale = 1/rate, log = FALSE) pgpois(q, shape, rate, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) rgpois(n, shape, rate, scale = 1/rate)
dgpois(x, shape, rate, scale = 1/rate, log = FALSE) pgpois(q, shape, rate, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) rgpois(n, shape, rate, scale = 1/rate)
x , q
|
vector of quantiles. |
shape , scale
|
shape and scale parameters. Must be positive, scale strictly. |
rate |
an alternative way to specify the scale. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
Gamma-Poisson distribution arises as a continuous mixture of
Poisson distributions, where the mixing distribution
of the Poisson rate is a gamma distribution.
When
and
, then
.
Probability mass function
Cumulative distribution function is calculated using recursive algorithm that employs the fact that
. This enables re-writing probability mass function as
what makes recursive updating from to
easy using the properties of factorials
and let's us efficiently calculate cumulative distribution function as a sum of probability mass functions
x <- rgpois(1e5, 7, 0.002) xx <- seq(0, 12000, by = 1) hist(x, 100, freq = FALSE) lines(xx, dgpois(xx, 7, 0.002), col = "red") hist(pgpois(x, 7, 0.002)) xx <- seq(0, 12000, by = 0.1) plot(ecdf(x)) lines(xx, pgpois(xx, 7, 0.002), col = "red", lwd = 2)
x <- rgpois(1e5, 7, 0.002) xx <- seq(0, 12000, by = 1) hist(x, 100, freq = FALSE) lines(xx, dgpois(xx, 7, 0.002), col = "red") hist(pgpois(x, 7, 0.002)) xx <- seq(0, 12000, by = 0.1) plot(ecdf(x)) lines(xx, pgpois(xx, 7, 0.002), col = "red", lwd = 2)
Density, distribution function, quantile function and random generation for the generalized extreme value distribution.
dgev(x, mu = 0, sigma = 1, xi = 0, log = FALSE) pgev(q, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) qgev(p, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) rgev(n, mu = 0, sigma = 1, xi = 0)
dgev(x, mu = 0, sigma = 1, xi = 0, log = FALSE) pgev(q, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) qgev(p, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) rgev(n, mu = 0, sigma = 1, xi = 0)
x , q
|
vector of quantiles. |
mu , sigma , xi
|
location, scale, and shape parameters. Scale must be positive. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
Coles, S. (2001). An Introduction to Statistical Modeling of Extreme Values. Springer.
curve(dgev(x, xi = -1/2), -4, 4, col = "green", ylab = "") curve(dgev(x, xi = 0), -4, 4, col = "red", add = TRUE) curve(dgev(x, xi = 1/2), -4, 4, col = "blue", add = TRUE) legend("topleft", col = c("green", "red", "blue"), lty = 1, legend = expression(xi == -1/2, xi == 0, xi == 1/2), bty = "n") x <- rgev(1e5, 5, 2, .5) hist(x, 1000, freq = FALSE, xlim = c(0, 50)) curve(dgev(x, 5, 2, .5), 0, 50, col = "red", add = TRUE, n = 5000) hist(pgev(x, 5, 2, .5)) plot(ecdf(x), xlim = c(0, 50)) curve(pgev(x, 5, 2, .5), 0, 50, col = "red", lwd = 2, add = TRUE)
curve(dgev(x, xi = -1/2), -4, 4, col = "green", ylab = "") curve(dgev(x, xi = 0), -4, 4, col = "red", add = TRUE) curve(dgev(x, xi = 1/2), -4, 4, col = "blue", add = TRUE) legend("topleft", col = c("green", "red", "blue"), lty = 1, legend = expression(xi == -1/2, xi == 0, xi == 1/2), bty = "n") x <- rgev(1e5, 5, 2, .5) hist(x, 1000, freq = FALSE, xlim = c(0, 50)) curve(dgev(x, 5, 2, .5), 0, 50, col = "red", add = TRUE, n = 5000) hist(pgev(x, 5, 2, .5)) plot(ecdf(x), xlim = c(0, 50)) curve(pgev(x, 5, 2, .5), 0, 50, col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the Gompertz distribution.
dgompertz(x, a = 1, b = 1, log = FALSE) pgompertz(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) qgompertz(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) rgompertz(n, a = 1, b = 1)
dgompertz(x, a = 1, b = 1, log = FALSE) pgompertz(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) qgompertz(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) rgompertz(n, a = 1, b = 1)
x , q
|
vector of quantiles. |
a , b
|
positive valued scale and location parameters. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
Lenart, A. (2012). The Gompertz distribution and Maximum Likelihood Estimation of its parameters - a revision. MPIDR WORKING PAPER WP 2012-008. https://www.demogr.mpg.de/papers/working/wp-2012-008.pdf
x <- rgompertz(1e5, 5, 2) hist(x, 100, freq = FALSE) curve(dgompertz(x, 5, 2), 0, 1, col = "red", add = TRUE) hist(pgompertz(x, 5, 2)) plot(ecdf(x)) curve(pgompertz(x, 5, 2), 0, 1, col = "red", lwd = 2, add = TRUE)
x <- rgompertz(1e5, 5, 2) hist(x, 100, freq = FALSE) curve(dgompertz(x, 5, 2), 0, 1, col = "red", add = TRUE) hist(pgompertz(x, 5, 2)) plot(ecdf(x)) curve(pgompertz(x, 5, 2), 0, 1, col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the generalized Pareto distribution.
dgpd(x, mu = 0, sigma = 1, xi = 0, log = FALSE) pgpd(q, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) qgpd(p, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) rgpd(n, mu = 0, sigma = 1, xi = 0)
dgpd(x, mu = 0, sigma = 1, xi = 0, log = FALSE) pgpd(q, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) qgpd(p, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) rgpd(n, mu = 0, sigma = 1, xi = 0)
x , q
|
vector of quantiles. |
mu , sigma , xi
|
location, scale, and shape parameters. Scale must be positive. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
Coles, S. (2001). An Introduction to Statistical Modeling of Extreme Values. Springer.
x <- rgpd(1e5, 5, 2, .1) hist(x, 100, freq = FALSE, xlim = c(0, 50)) curve(dgpd(x, 5, 2, .1), 0, 50, col = "red", add = TRUE, n = 5000) hist(pgpd(x, 5, 2, .1)) plot(ecdf(x)) curve(pgpd(x, 5, 2, .1), 0, 50, col = "red", lwd = 2, add = TRUE)
x <- rgpd(1e5, 5, 2, .1) hist(x, 100, freq = FALSE, xlim = c(0, 50)) curve(dgpd(x, 5, 2, .1), 0, 50, col = "red", add = TRUE, n = 5000) hist(pgpd(x, 5, 2, .1)) plot(ecdf(x)) curve(pgpd(x, 5, 2, .1), 0, 50, col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the Gumbel distribution.
dgumbel(x, mu = 0, sigma = 1, log = FALSE) pgumbel(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qgumbel(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rgumbel(n, mu = 0, sigma = 1)
dgumbel(x, mu = 0, sigma = 1, log = FALSE) pgumbel(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qgumbel(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rgumbel(n, mu = 0, sigma = 1)
x , q
|
vector of quantiles. |
mu , sigma
|
location and scale parameters. Scale must be positive. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
Bury, K. (1999). Statistical Distributions in Engineering. Cambridge University Press.
x <- rgumbel(1e5, 5, 2) hist(x, 100, freq = FALSE) curve(dgumbel(x, 5, 2), 0, 25, col = "red", add = TRUE) hist(pgumbel(x, 5, 2)) plot(ecdf(x)) curve(pgumbel(x, 5, 2), 0, 25, col = "red", lwd = 2, add = TRUE)
x <- rgumbel(1e5, 5, 2) hist(x, 100, freq = FALSE) curve(dgumbel(x, 5, 2), 0, 25, col = "red", add = TRUE) hist(pgumbel(x, 5, 2)) plot(ecdf(x)) curve(pgumbel(x, 5, 2), 0, 25, col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the half-Cauchy distribution.
dhcauchy(x, sigma = 1, log = FALSE) phcauchy(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) qhcauchy(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) rhcauchy(n, sigma = 1)
dhcauchy(x, sigma = 1, log = FALSE) phcauchy(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) qhcauchy(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) rhcauchy(n, sigma = 1)
x , q
|
vector of quantiles. |
sigma |
positive valued scale parameter. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
If follows Cauchy centered at 0 and parametrized by scale
,
then
follows half-Cauchy distribution parametrized by
scale
. Half-Cauchy distribution is a special case of half-t
distribution with
degrees of freedom.
Gelman, A. (2006). Prior distributions for variance parameters in hierarchical models (comment on article by Browne and Draper). Bayesian analysis, 1(3), 515-534.
Jacob, E. and Jayakumar, K. (2012). On Half-Cauchy Distribution and Process. International Journal of Statistika and Mathematika, 3(2), 77-81.
x <- rhcauchy(1e5, 2) hist(x, 2e5, freq = FALSE, xlim = c(0, 100)) curve(dhcauchy(x, 2), 0, 100, col = "red", add = TRUE) hist(phcauchy(x, 2)) plot(ecdf(x), xlim = c(0, 100)) curve(phcauchy(x, 2), col = "red", lwd = 2, add = TRUE)
x <- rhcauchy(1e5, 2) hist(x, 2e5, freq = FALSE, xlim = c(0, 100)) curve(dhcauchy(x, 2), 0, 100, col = "red", add = TRUE) hist(phcauchy(x, 2)) plot(ecdf(x), xlim = c(0, 100)) curve(phcauchy(x, 2), col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the half-normal distribution.
dhnorm(x, sigma = 1, log = FALSE) phnorm(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) qhnorm(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) rhnorm(n, sigma = 1)
dhnorm(x, sigma = 1, log = FALSE) phnorm(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) qhnorm(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) rhnorm(n, sigma = 1)
x , q
|
vector of quantiles. |
sigma |
positive valued scale parameter. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
If follows normal distribution centered at 0 and parametrized
by scale
, then
follows half-normal distribution
parametrized by scale
. Half-t distribution with
degrees of freedom converges to half-normal distribution.
Gelman, A. (2006). Prior distributions for variance parameters in hierarchical models (comment on article by Browne and Draper). Bayesian analysis, 1(3), 515-534.
Jacob, E. and Jayakumar, K. (2012). On Half-Cauchy Distribution and Process. International Journal of Statistika and Mathematika, 3(2), 77-81.
x <- rhnorm(1e5, 2) hist(x, 100, freq = FALSE) curve(dhnorm(x, 2), 0, 8, col = "red", add = TRUE) hist(phnorm(x, 2)) plot(ecdf(x)) curve(phnorm(x, 2), 0, 8, col = "red", lwd = 2, add = TRUE)
x <- rhnorm(1e5, 2) hist(x, 100, freq = FALSE) curve(dhnorm(x, 2), 0, 8, col = "red", add = TRUE) hist(phnorm(x, 2)) plot(ecdf(x)) curve(phnorm(x, 2), 0, 8, col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the half-t distribution.
dht(x, nu, sigma = 1, log = FALSE) pht(q, nu, sigma = 1, lower.tail = TRUE, log.p = FALSE) qht(p, nu, sigma = 1, lower.tail = TRUE, log.p = FALSE) rht(n, nu, sigma = 1)
dht(x, nu, sigma = 1, log = FALSE) pht(q, nu, sigma = 1, lower.tail = TRUE, log.p = FALSE) qht(p, nu, sigma = 1, lower.tail = TRUE, log.p = FALSE) rht(n, nu, sigma = 1)
x , q
|
vector of quantiles. |
nu , sigma
|
positive valued degrees of freedom and scale parameters. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
If follows t distribution parametrized by degrees of freedom
and scale
, then
follows half-t distribution parametrized
by degrees of freedom
and scale
.
Gelman, A. (2006). Prior distributions for variance parameters in hierarchical models (comment on article by Browne and Draper). Bayesian analysis, 1(3), 515-534.
Jacob, E. and Jayakumar, K. (2012). On Half-Cauchy Distribution and Process. International Journal of Statistika and Mathematika, 3(2), 77-81.
x <- rht(1e5, 2, 2) hist(x, 500, freq = FALSE, xlim = c(0, 100)) curve(dht(x, 2, 2), 0, 100, col = "red", add = TRUE) hist(pht(x, 2, 2)) plot(ecdf(x), xlim = c(0, 100)) curve(pht(x, 2, 2), 0, 100, col = "red", lwd = 2, add = TRUE)
x <- rht(1e5, 2, 2) hist(x, 500, freq = FALSE, xlim = c(0, 100)) curve(dht(x, 2, 2), 0, 100, col = "red", add = TRUE) hist(pht(x, 2, 2)) plot(ecdf(x), xlim = c(0, 100)) curve(pht(x, 2, 2), 0, 100, col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the "Huber density" distribution.
dhuber(x, mu = 0, sigma = 1, epsilon = 1.345, log = FALSE) phuber(q, mu = 0, sigma = 1, epsilon = 1.345, lower.tail = TRUE, log.p = FALSE) qhuber(p, mu = 0, sigma = 1, epsilon = 1.345, lower.tail = TRUE, log.p = FALSE) rhuber(n, mu = 0, sigma = 1, epsilon = 1.345)
dhuber(x, mu = 0, sigma = 1, epsilon = 1.345, log = FALSE) phuber(q, mu = 0, sigma = 1, epsilon = 1.345, lower.tail = TRUE, log.p = FALSE) qhuber(p, mu = 0, sigma = 1, epsilon = 1.345, lower.tail = TRUE, log.p = FALSE) rhuber(n, mu = 0, sigma = 1, epsilon = 1.345)
x , q
|
vector of quantiles. |
mu , sigma , epsilon
|
location, and scale, and shape parameters. Scale and shape must be positive. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Huber density is connected to Huber loss and can be defined as:
where
Huber, P.J. (1964). Robust Estimation of a Location Parameter. Annals of Statistics, 53(1), 73-101.
Huber, P.J. (1981). Robust Statistics. Wiley.
Schumann, D. (2009). Robust Variable Selection. ProQuest.
x <- rhuber(1e5, 5, 2, 3) hist(x, 100, freq = FALSE) curve(dhuber(x, 5, 2, 3), -20, 20, col = "red", add = TRUE, n = 5000) hist(phuber(x, 5, 2, 3)) plot(ecdf(x)) curve(phuber(x, 5, 2, 3), -20, 20, col = "red", lwd = 2, add = TRUE)
x <- rhuber(1e5, 5, 2, 3) hist(x, 100, freq = FALSE) curve(dhuber(x, 5, 2, 3), -20, 20, col = "red", add = TRUE, n = 5000) hist(phuber(x, 5, 2, 3)) plot(ecdf(x)) curve(phuber(x, 5, 2, 3), -20, 20, col = "red", lwd = 2, add = TRUE)
Density, distribution function and random generation for the inverse chi-squared distribution and scaled chi-squared distribution.
dinvchisq(x, nu, tau, log = FALSE) pinvchisq(q, nu, tau, lower.tail = TRUE, log.p = FALSE) qinvchisq(p, nu, tau, lower.tail = TRUE, log.p = FALSE) rinvchisq(n, nu, tau)
dinvchisq(x, nu, tau, log = FALSE) pinvchisq(q, nu, tau, lower.tail = TRUE, log.p = FALSE) qinvchisq(p, nu, tau, lower.tail = TRUE, log.p = FALSE) rinvchisq(n, nu, tau)
x , q
|
vector of quantiles. |
nu |
positive valued shape parameter. |
tau |
positive valued scaling parameter; if provided it returns values for scaled chi-squared distributions. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
If follows
distribution, then
follows inverse
chi-squared distribution parametrized by
. Inverse chi-squared distribution
is a special case of inverse gamma distribution with parameters
and
;
or
and
for scaled inverse
chi-squared distribution.
x <- rinvchisq(1e5, 20) hist(x, 100, freq = FALSE) curve(dinvchisq(x, 20), 0, 1, n = 501, col = "red", add = TRUE) hist(pinvchisq(x, 20)) plot(ecdf(x)) curve(pinvchisq(x, 20), 0, 1, n = 501, col = "red", lwd = 2, add = TRUE) # scaled x <- rinvchisq(1e5, 10, 5) hist(x, 100, freq = FALSE) curve(dinvchisq(x, 10, 5), 0, 150, n = 501, col = "red", add = TRUE) hist(pinvchisq(x, 10, 5)) plot(ecdf(x)) curve(pinvchisq(x, 10, 5), 0, 150, n = 501, col = "red", lwd = 2, add = TRUE)
x <- rinvchisq(1e5, 20) hist(x, 100, freq = FALSE) curve(dinvchisq(x, 20), 0, 1, n = 501, col = "red", add = TRUE) hist(pinvchisq(x, 20)) plot(ecdf(x)) curve(pinvchisq(x, 20), 0, 1, n = 501, col = "red", lwd = 2, add = TRUE) # scaled x <- rinvchisq(1e5, 10, 5) hist(x, 100, freq = FALSE) curve(dinvchisq(x, 10, 5), 0, 150, n = 501, col = "red", add = TRUE) hist(pinvchisq(x, 10, 5)) plot(ecdf(x)) curve(pinvchisq(x, 10, 5), 0, 150, n = 501, col = "red", lwd = 2, add = TRUE)
Density, distribution function and random generation for the inverse-gamma distribution.
dinvgamma(x, alpha, beta = 1, log = FALSE) pinvgamma(q, alpha, beta = 1, lower.tail = TRUE, log.p = FALSE) qinvgamma(p, alpha, beta = 1, lower.tail = TRUE, log.p = FALSE) rinvgamma(n, alpha, beta = 1)
dinvgamma(x, alpha, beta = 1, log = FALSE) pinvgamma(q, alpha, beta = 1, lower.tail = TRUE, log.p = FALSE) qinvgamma(p, alpha, beta = 1, lower.tail = TRUE, log.p = FALSE) rinvgamma(n, alpha, beta = 1)
x , q
|
vector of quantiles. |
alpha , beta
|
positive valued shape and scale parameters. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability mass function
Cumulative distribution function
Witkovsky, V. (2001). Computing the distribution of a linear combination of inverted gamma variables. Kybernetika 37(1), 79-90.
Leemis, L.M. and McQueston, L.T. (2008). Univariate Distribution Relationships. American Statistician 62(1): 45-53.
x <- rinvgamma(1e5, 20, 3) hist(x, 100, freq = FALSE) curve(dinvgamma(x, 20, 3), 0, 1, col = "red", add = TRUE, n = 5000) hist(pinvgamma(x, 20, 3)) plot(ecdf(x)) curve(pinvgamma(x, 20, 3), 0, 1, col = "red", lwd = 2, add = TRUE, n = 5000)
x <- rinvgamma(1e5, 20, 3) hist(x, 100, freq = FALSE) curve(dinvgamma(x, 20, 3), 0, 1, col = "red", add = TRUE, n = 5000) hist(pinvgamma(x, 20, 3)) plot(ecdf(x)) curve(pinvgamma(x, 20, 3), 0, 1, col = "red", lwd = 2, add = TRUE, n = 5000)
Density, distribution function, quantile function and random generation for the Kumaraswamy distribution.
dkumar(x, a = 1, b = 1, log = FALSE) pkumar(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) qkumar(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) rkumar(n, a = 1, b = 1)
dkumar(x, a = 1, b = 1, log = FALSE) pkumar(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) qkumar(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) rkumar(n, a = 1, b = 1)
x , q
|
vector of quantiles. |
a , b
|
positive valued parameters. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with some tractability advantages. Statistical Methodology, 6, 70-81.
Cordeiro, G.M. and de Castro, M. (2009). A new family of generalized distributions. Journal of Statistical Computation & Simulation, 1-17.
x <- rkumar(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dkumar(x, 5, 16), 0, 1, col = "red", add = TRUE) hist(pkumar(x, 5, 16)) plot(ecdf(x)) curve(pkumar(x, 5, 16), 0, 1, col = "red", lwd = 2, add = TRUE)
x <- rkumar(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dkumar(x, 5, 16), 0, 1, col = "red", add = TRUE) hist(pkumar(x, 5, 16)) plot(ecdf(x)) curve(pkumar(x, 5, 16), 0, 1, col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the Laplace distribution.
dlaplace(x, mu = 0, sigma = 1, log = FALSE) plaplace(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qlaplace(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rlaplace(n, mu = 0, sigma = 1)
dlaplace(x, mu = 0, sigma = 1, log = FALSE) plaplace(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qlaplace(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rlaplace(n, mu = 0, sigma = 1)
x , q
|
vector of quantiles. |
mu , sigma
|
location and scale parameters. Scale must be positive. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications. Chapman & Hall/CRC
Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). Statistical Distributions. John Wiley & Sons.
x <- rlaplace(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dlaplace(x, 5, 16), -200, 200, n = 500, col = "red", add = TRUE) hist(plaplace(x, 5, 16)) plot(ecdf(x)) curve(plaplace(x, 5, 16), -200, 200, n = 500, col = "red", lwd = 2, add = TRUE)
x <- rlaplace(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dlaplace(x, 5, 16), -200, 200, n = 500, col = "red", add = TRUE) hist(plaplace(x, 5, 16)) plot(ecdf(x)) curve(plaplace(x, 5, 16), -200, 200, n = 500, col = "red", lwd = 2, add = TRUE)
Probability mass function, distribution function and random generation
for location-scale version of the t-distribution. Location-scale version
of the t-distribution besides degrees of freedom , is parametrized
using additional parameters
for location and
for
scale (
and
for standard t-distribution).
dlst(x, df, mu = 0, sigma = 1, log = FALSE) plst(q, df, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qlst(p, df, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rlst(n, df, mu = 0, sigma = 1)
dlst(x, df, mu = 0, sigma = 1, log = FALSE) plst(q, df, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qlst(p, df, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rlst(n, df, mu = 0, sigma = 1)
x , q
|
vector of quantiles. |
df |
degrees of freedom (> 0, maybe non-integer). |
mu |
vector of locations |
sigma |
vector of positive valued scale parameters. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
x <- rlst(1e5, 1000, 5, 13) hist(x, 100, freq = FALSE) curve(dlst(x, 1000, 5, 13), -60, 60, col = "red", add = TRUE) hist(plst(x, 1000, 5, 13)) plot(ecdf(x)) curve(plst(x, 1000, 5, 13), -60, 60, col = "red", lwd = 2, add = TRUE)
x <- rlst(1e5, 1000, 5, 13) hist(x, 100, freq = FALSE) curve(dlst(x, 1000, 5, 13), -60, 60, col = "red", add = TRUE) hist(plst(x, 1000, 5, 13)) plot(ecdf(x)) curve(plst(x, 1000, 5, 13), -60, 60, col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the logarithmic series distribution.
dlgser(x, theta, log = FALSE) plgser(q, theta, lower.tail = TRUE, log.p = FALSE) qlgser(p, theta, lower.tail = TRUE, log.p = FALSE) rlgser(n, theta)
dlgser(x, theta, log = FALSE) plgser(q, theta, lower.tail = TRUE, log.p = FALSE) qlgser(p, theta, lower.tail = TRUE, log.p = FALSE) rlgser(n, theta)
x , q
|
vector of quantiles. |
theta |
vector; concentration parameter; ( |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability mass function
Cumulative distribution function
Quantile function and random generation are computed using algorithm described in Krishnamoorthy (2006).
Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications. Chapman & Hall/CRC
Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). Statistical Distributions. John Wiley & Sons.
x <- rlgser(1e5, 0.66) xx <- seq(0, 100, by = 1) plot(prop.table(table(x)), type = "h") lines(xx, dlgser(xx, 0.66), col = "red") # Notice: distribution of F(X) is far from uniform: hist(plgser(x, 0.66), 50) xx <- seq(0, 100, by = 0.01) plot(ecdf(x)) lines(xx, plgser(xx, 0.66), col = "red", lwd = 2)
x <- rlgser(1e5, 0.66) xx <- seq(0, 100, by = 1) plot(prop.table(table(x)), type = "h") lines(xx, dlgser(xx, 0.66), col = "red") # Notice: distribution of F(X) is far from uniform: hist(plgser(x, 0.66), 50) xx <- seq(0, 100, by = 0.01) plot(ecdf(x)) lines(xx, plgser(xx, 0.66), col = "red", lwd = 2)
Density, distribution function, quantile function and random generation for the Lomax distribution.
dlomax(x, lambda, kappa, log = FALSE) plomax(q, lambda, kappa, lower.tail = TRUE, log.p = FALSE) qlomax(p, lambda, kappa, lower.tail = TRUE, log.p = FALSE) rlomax(n, lambda, kappa)
dlomax(x, lambda, kappa, log = FALSE) plomax(q, lambda, kappa, lower.tail = TRUE, log.p = FALSE) qlomax(p, lambda, kappa, lower.tail = TRUE, log.p = FALSE) rlomax(n, lambda, kappa)
x , q
|
vector of quantiles. |
lambda , kappa
|
positive valued parameters. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
x <- rlomax(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dlomax(x, 5, 16), 0, 1, col = "red", add = TRUE, n = 5000) hist(plomax(x, 5, 16)) plot(ecdf(x)) curve(plomax(x, 5, 16), 0, 1, col = "red", lwd = 2, add = TRUE)
x <- rlomax(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dlomax(x, 5, 16), 0, 1, col = "red", add = TRUE, n = 5000) hist(plomax(x, 5, 16)) plot(ecdf(x)) curve(plomax(x, 5, 16), 0, 1, col = "red", lwd = 2, add = TRUE)
Probability mass function and random generation for the multivariate hypergeometric distribution.
dmvhyper(x, n, k, log = FALSE) rmvhyper(nn, n, k)
dmvhyper(x, n, k, log = FALSE) rmvhyper(nn, n, k)
x |
|
n |
|
k |
the number of balls drawn from the urn. |
log |
logical; if TRUE, probabilities p are given as log(p). |
nn |
number of observations. If |
Probability mass function
The multivariate hypergeometric distribution is generalization of
hypergeometric distribution. It is used for sampling without replacement
out of
marbles in
colors, where each of the colors appears
times. Where
,
and
.
Gentle, J.E. (2006). Random number generation and Monte Carlo methods. Springer.
# Generating 10 random draws from multivariate hypergeometric # distribution parametrized using a vector rmvhyper(10, c(10, 12, 5, 8, 11), 33)
# Generating 10 random draws from multivariate hypergeometric # distribution parametrized using a vector rmvhyper(10, c(10, 12, 5, 8, 11), 33)
Probability mass function and random generation for the multinomial distribution.
dmnom(x, size, prob, log = FALSE) rmnom(n, size, prob)
dmnom(x, size, prob, log = FALSE) rmnom(n, size, prob)
x |
|
size |
numeric vector; number of trials (zero or more). |
prob |
|
log |
logical; if TRUE, probabilities p are given as log(p). |
n |
number of observations. If |
Probability mass function
Gentle, J.E. (2006). Random number generation and Monte Carlo methods. Springer.
# Generating 10 random draws from multinomial distribution # parametrized using a vector (x <- rmnom(10, 3, c(1/3, 1/3, 1/3))) # Results are consistent with dmultinom() from stats: all.equal(dmultinom(x[1,], 3, c(1/3, 1/3, 1/3)), dmnom(x[1, , drop = FALSE], 3, c(1/3, 1/3, 1/3)))
# Generating 10 random draws from multinomial distribution # parametrized using a vector (x <- rmnom(10, 3, c(1/3, 1/3, 1/3))) # Results are consistent with dmultinom() from stats: all.equal(dmultinom(x[1,], 3, c(1/3, 1/3, 1/3)), dmnom(x[1, , drop = FALSE], 3, c(1/3, 1/3, 1/3)))
Probability mass function, distribution function, quantile function and random generation for the negative hypergeometric distribution.
dnhyper(x, n, m, r, log = FALSE) pnhyper(q, n, m, r, lower.tail = TRUE, log.p = FALSE) qnhyper(p, n, m, r, lower.tail = TRUE, log.p = FALSE) rnhyper(nn, n, m, r)
dnhyper(x, n, m, r, log = FALSE) pnhyper(q, n, m, r, lower.tail = TRUE, log.p = FALSE) qnhyper(p, n, m, r, lower.tail = TRUE, log.p = FALSE) rnhyper(nn, n, m, r)
x , q
|
vector of quantiles representing the number of balls drawn without replacement from an urn which contains both black and white balls. |
n |
the number of black balls in the urn. |
m |
the number of white balls in the urn. |
r |
the number of white balls that needs to be drawn for the sampling to be stopped. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
nn |
number of observations. If |
Negative hypergeometric distribution describes number of balls observed
until drawing without replacement to obtain
white balls
from the urn containing
white balls and
black balls,
and is defined as
The algorithm used for calculating probability mass function, cumulative distribution function and quantile function is based on Fortran program NHYPERG created by Berry and Mielke (1996, 1998). Random generation is done by inverse transform sampling.
Berry, K. J., & Mielke, P. W. (1998). The negative hypergeometric probability distribution: Sampling without replacement from a finite population. Perceptual and motor skills, 86(1), 207-210. https://journals.sagepub.com/doi/10.2466/pms.1998.86.1.207
Berry, K. J., & Mielke, P. W. (1996). Exact confidence limits for population proportions based on the negative hypergeometric probability distribution. Perceptual and motor skills, 83(3 suppl), 1216-1218. https://journals.sagepub.com/doi/10.2466/pms.1996.83.3f.1216
Schuster, E. F., & Sype, W. R. (1987). On the negative hypergeometric distribution. International Journal of Mathematical Education in Science and Technology, 18(3), 453-459.
Chae, K. C. (1993). Presenting the negative hypergeometric distribution to the introductory statistics courses. International Journal of Mathematical Education in Science and Technology, 24(4), 523-526.
Jones, S.N. (2013). A Gaming Application of the Negative Hypergeometric Distribution. UNLV Theses, Dissertations, Professional Papers, and Capstones. Paper 1846. https://digitalscholarship.unlv.edu/cgi/viewcontent.cgi?referer=&httpsredir=1&article=2847&context=thesesdissertations
x <- rnhyper(1e5, 60, 35, 15) xx <- 15:95 plot(prop.table(table(x))) lines(xx, dnhyper(xx, 60, 35, 15), col = "red") hist(pnhyper(x, 60, 35, 15)) xx <- seq(0, 100, by = 0.01) plot(ecdf(x)) lines(xx, pnhyper(xx, 60, 35, 15), col = "red", lwd = 2)
x <- rnhyper(1e5, 60, 35, 15) xx <- 15:95 plot(prop.table(table(x))) lines(xx, dnhyper(xx, 60, 35, 15), col = "red") hist(pnhyper(x, 60, 35, 15)) xx <- seq(0, 100, by = 0.01) plot(ecdf(x)) lines(xx, pnhyper(xx, 60, 35, 15), col = "red", lwd = 2)
Density, distribution function and random generation for the mixture of normal distributions.
dmixnorm(x, mean, sd, alpha, log = FALSE) pmixnorm(q, mean, sd, alpha, lower.tail = TRUE, log.p = FALSE) rmixnorm(n, mean, sd, alpha)
dmixnorm(x, mean, sd, alpha, log = FALSE) pmixnorm(q, mean, sd, alpha, lower.tail = TRUE, log.p = FALSE) rmixnorm(n, mean, sd, alpha)
x , q
|
vector of quantiles. |
mean |
matrix (or vector) of means. |
sd |
matrix (or vector) of standard deviations. |
alpha |
matrix (or vector) of mixing proportions; mixing proportions need to sum up to 1. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
p |
vector of probabilities. |
Probability density function
Cumulative distribution function
where .
x <- rmixnorm(1e5, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)) hist(x, 100, freq = FALSE) curve(dmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), -20, 20, n = 500, col = "red", add = TRUE) hist(pmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3))) plot(ecdf(x)) curve(pmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), -20, 20, n = 500, col = "red", lwd = 2, add = TRUE)
x <- rmixnorm(1e5, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)) hist(x, 100, freq = FALSE) curve(dmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), -20, 20, n = 500, col = "red", add = TRUE) hist(pmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3))) plot(ecdf(x)) curve(pmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), -20, 20, n = 500, col = "red", lwd = 2, add = TRUE)
Non-standard form of beta distribution with lower and upper bounds
denoted as min
and max
. By default min=0
and max=1
what leads to standard beta distribution.
dnsbeta(x, shape1, shape2, min = 0, max = 1, log = FALSE) pnsbeta(q, shape1, shape2, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE) qnsbeta(p, shape1, shape2, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE) rnsbeta(n, shape1, shape2, min = 0, max = 1)
dnsbeta(x, shape1, shape2, min = 0, max = 1, log = FALSE) pnsbeta(q, shape1, shape2, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE) qnsbeta(p, shape1, shape2, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE) rnsbeta(n, shape1, shape2, min = 0, max = 1)
x , q
|
vector of quantiles. |
shape1 , shape2
|
non-negative parameters of the Beta distribution. |
min , max
|
lower and upper bounds. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
x <- rnsbeta(1e5, 5, 13, -4, 8) hist(x, 100, freq = FALSE) curve(dnsbeta(x, 5, 13, -4, 8), -4, 6, col = "red", add = TRUE) hist(pnsbeta(x, 5, 13, -4, 8)) plot(ecdf(x)) curve(pnsbeta(x, 5, 13, -4, 8), -4, 6, col = "red", lwd = 2, add = TRUE)
x <- rnsbeta(1e5, 5, 13, -4, 8) hist(x, 100, freq = FALSE) curve(dnsbeta(x, 5, 13, -4, 8), -4, 6, col = "red", add = TRUE) hist(pnsbeta(x, 5, 13, -4, 8)) plot(ecdf(x)) curve(pnsbeta(x, 5, 13, -4, 8), -4, 6, col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the Pareto distribution.
dpareto(x, a = 1, b = 1, log = FALSE) ppareto(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) qpareto(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) rpareto(n, a = 1, b = 1)
dpareto(x, a = 1, b = 1, log = FALSE) ppareto(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) qpareto(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) rpareto(n, a = 1, b = 1)
x , q
|
vector of quantiles. |
a , b
|
positive valued scale and location parameters. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications. Chapman & Hall/CRC
x <- rpareto(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dpareto(x, 5, 16), 0, 200, col = "red", add = TRUE) hist(ppareto(x, 5, 16)) plot(ecdf(x)) curve(ppareto(x, 5, 16), 0, 200, col = "red", lwd = 2, add = TRUE)
x <- rpareto(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dpareto(x, 5, 16), 0, 200, col = "red", add = TRUE) hist(ppareto(x, 5, 16)) plot(ecdf(x)) curve(ppareto(x, 5, 16), 0, 200, col = "red", lwd = 2, add = TRUE)
Density, distribution function and random generation for the mixture of Poisson distributions.
dmixpois(x, lambda, alpha, log = FALSE) pmixpois(q, lambda, alpha, lower.tail = TRUE, log.p = FALSE) rmixpois(n, lambda, alpha)
dmixpois(x, lambda, alpha, log = FALSE) pmixpois(q, lambda, alpha, lower.tail = TRUE, log.p = FALSE) rmixpois(n, lambda, alpha)
x , q
|
vector of quantiles. |
lambda |
matrix (or vector) of (non-negative) means. |
alpha |
matrix (or vector) of mixing proportions; mixing proportions need to sum up to 1. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
p |
vector of probabilities. |
Probability density function
Cumulative distribution function
where .
x <- rmixpois(1e5, c(5, 12, 19), c(1/3, 1/3, 1/3)) xx <- seq(-1, 50) plot(prop.table(table(x))) lines(xx, dmixpois(xx, c(5, 12, 19), c(1/3, 1/3, 1/3)), col = "red") hist(pmixpois(x, c(5, 12, 19), c(1/3, 1/3, 1/3))) xx <- seq(0, 50, by = 0.01) plot(ecdf(x)) lines(xx, pmixpois(xx, c(5, 12, 19), c(1/3, 1/3, 1/3)), col = "red", lwd = 2)
x <- rmixpois(1e5, c(5, 12, 19), c(1/3, 1/3, 1/3)) xx <- seq(-1, 50) plot(prop.table(table(x))) lines(xx, dmixpois(xx, c(5, 12, 19), c(1/3, 1/3, 1/3)), col = "red") hist(pmixpois(x, c(5, 12, 19), c(1/3, 1/3, 1/3))) xx <- seq(0, 50, by = 0.01) plot(ecdf(x)) lines(xx, pmixpois(xx, c(5, 12, 19), c(1/3, 1/3, 1/3)), col = "red", lwd = 2)
Density, distribution function, quantile function and random generation for the power distribution.
dpower(x, alpha, beta, log = FALSE) ppower(q, alpha, beta, lower.tail = TRUE, log.p = FALSE) qpower(p, alpha, beta, lower.tail = TRUE, log.p = FALSE) rpower(n, alpha, beta)
dpower(x, alpha, beta, log = FALSE) ppower(q, alpha, beta, lower.tail = TRUE, log.p = FALSE) qpower(p, alpha, beta, lower.tail = TRUE, log.p = FALSE) rpower(n, alpha, beta)
x , q
|
vector of quantiles. |
alpha , beta
|
parameters. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
x <- rpower(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dpower(x, 5, 16), 2, 6, col = "red", add = TRUE, n = 5000) hist(ppower(x, 5, 16)) plot(ecdf(x)) curve(ppower(x, 5, 16), 2, 6, col = "red", lwd = 2, add = TRUE)
x <- rpower(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dpower(x, 5, 16), 2, 6, col = "red", add = TRUE, n = 5000) hist(ppower(x, 5, 16)) plot(ecdf(x)) curve(ppower(x, 5, 16), 2, 6, col = "red", lwd = 2, add = TRUE)
Probability mass function, distribution function and random generation for the reparametrized beta distribution.
dprop(x, size, mean, prior = 0, log = FALSE) pprop(q, size, mean, prior = 0, lower.tail = TRUE, log.p = FALSE) qprop(p, size, mean, prior = 0, lower.tail = TRUE, log.p = FALSE) rprop(n, size, mean, prior = 0)
dprop(x, size, mean, prior = 0, log = FALSE) pprop(q, size, mean, prior = 0, lower.tail = TRUE, log.p = FALSE) qprop(p, size, mean, prior = 0, lower.tail = TRUE, log.p = FALSE) rprop(n, size, mean, prior = 0)
x , q
|
vector of quantiles. |
size |
non-negative real number; precision or number of binomial trials. |
mean |
mean proportion or probability of success on each trial;
|
prior |
(see below) with |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Beta can be understood as a distribution of proportions in
trials where the average proportion is denoted as
,
so it's parameters become
and
and it's density function becomes
where is a prior parameter, so the distribution is a
posterior distribution after observing
successes and
failures in
trials with binomial likelihood
and symmetric
prior for
probability of success. Parameter value
corresponds to
uniform prior;
corresponds to Jeffreys prior;
corresponds to "uninformative" Haldane prior, this is also the re-parametrized
distribution used in beta regression. With
the distribution
can be understood as a continuous analog to binomial distribution dealing
with proportions rather then counts. Alternatively
may be
understood as precision parameter (as in beta regression).
Notice that in pre-1.8.4 versions of this package, prior
was not settable
and by default fixed to one, instead of zero. To obtain the same results as in
the previous versions, use prior = 1
in each of the functions.
Ferrari, S., & Cribari-Neto, F. (2004). Beta regression for modelling rates and proportions. Journal of Applied Statistics, 31(7), 799-815.
Smithson, M., & Verkuilen, J. (2006). A better lemon squeezer? Maximum-likelihood regression with beta-distributed dependent variables. Psychological Methods, 11(1), 54-71.
x <- rprop(1e5, 100, 0.33) hist(x, 100, freq = FALSE) curve(dprop(x, 100, 0.33), 0, 1, col = "red", add = TRUE) hist(pprop(x, 100, 0.33)) plot(ecdf(x)) curve(pprop(x, 100, 0.33), 0, 1, col = "red", lwd = 2, add = TRUE) n <- 500 p <- 0.23 k <- rbinom(1e5, n, p) hist(k/n, freq = FALSE, 100) curve(dprop(x, n, p), 0, 1, col = "red", add = TRUE, n = 500)
x <- rprop(1e5, 100, 0.33) hist(x, 100, freq = FALSE) curve(dprop(x, 100, 0.33), 0, 1, col = "red", add = TRUE) hist(pprop(x, 100, 0.33)) plot(ecdf(x)) curve(pprop(x, 100, 0.33), 0, 1, col = "red", lwd = 2, add = TRUE) n <- 500 p <- 0.23 k <- rbinom(1e5, n, p) hist(k/n, freq = FALSE, 100) curve(dprop(x, n, p), 0, 1, col = "red", add = TRUE, n = 500)
Random generation for the Rademacher distribution (values -1 and +1 with equal probability).
rsign(n)
rsign(n)
n |
number of observations. If |
Density, distribution function, quantile function and random generation for the Rayleigh distribution.
drayleigh(x, sigma = 1, log = FALSE) prayleigh(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) qrayleigh(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) rrayleigh(n, sigma = 1)
drayleigh(x, sigma = 1, log = FALSE) prayleigh(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) qrayleigh(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) rrayleigh(n, sigma = 1)
x , q
|
vector of quantiles. |
sigma |
positive valued parameter. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications. Chapman & Hall/CRC.
Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). Statistical Distributions. John Wiley & Sons.
x <- rrayleigh(1e5, 13) hist(x, 100, freq = FALSE) curve(drayleigh(x, 13), 0, 60, col = "red", add = TRUE) hist(prayleigh(x, 13)) plot(ecdf(x)) curve(prayleigh(x, 13), 0, 60, col = "red", lwd = 2, add = TRUE)
x <- rrayleigh(1e5, 13) hist(x, 100, freq = FALSE) curve(drayleigh(x, 13), 0, 60, col = "red", add = TRUE) hist(prayleigh(x, 13)) plot(ecdf(x)) curve(prayleigh(x, 13), 0, 60, col = "red", lwd = 2, add = TRUE)
Density, distribution function, and random generation for the shifted Gompertz distribution.
dsgomp(x, b, eta, log = FALSE) psgomp(q, b, eta, lower.tail = TRUE, log.p = FALSE) rsgomp(n, b, eta)
dsgomp(x, b, eta, log = FALSE) psgomp(q, b, eta, lower.tail = TRUE, log.p = FALSE) rsgomp(n, b, eta)
x , q
|
vector of quantiles. |
b , eta
|
positive valued scale and shape parameters; both need to be positive. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
If follows exponential distribution parametrized by scale
and
follows reparametrized Gumbel distribution with cumulative distribution function
parametrized by
scale
and shape
, then
follows shifted
Gompertz distribution parametrized by scale
and shape
.
The above relation is used by
rsgomp
function for random generation from
shifted Gompertz distribution.
Probability density function
Cumulative distribution function
Bemmaor, A.C. (1994). Modeling the Diffusion of New Durable Goods: Word-of-Mouth Effect Versus Consumer Heterogeneity. [In:] G. Laurent, G.L. Lilien & B. Pras. Research Traditions in Marketing. Boston: Kluwer Academic Publishers. pp. 201-223.
Jimenez, T.F. and Jodra, P. (2009). A Note on the Moments and Computer Generation of the Shifted Gompertz Distribution. Communications in Statistics - Theory and Methods, 38(1), 78-89.
Jimenez T.F. (2014). Estimation of the Parameters of the Shifted Gompertz Distribution, Using Least Squares, Maximum Likelihood and Moments Methods. Journal of Computational and Applied Mathematics, 255(1), 867-877.
x <- rsgomp(1e5, 0.4, 1) hist(x, 50, freq = FALSE) curve(dsgomp(x, 0.4, 1), 0, 30, col = "red", add = TRUE) hist(psgomp(x, 0.4, 1)) plot(ecdf(x)) curve(psgomp(x, 0.4, 1), 0, 30, col = "red", lwd = 2, add = TRUE)
x <- rsgomp(1e5, 0.4, 1) hist(x, 50, freq = FALSE) curve(dsgomp(x, 0.4, 1), 0, 30, col = "red", add = TRUE) hist(psgomp(x, 0.4, 1)) plot(ecdf(x)) curve(psgomp(x, 0.4, 1), 0, 30, col = "red", lwd = 2, add = TRUE)
Probability mass function and random generation for the Skellam distribution.
dskellam(x, mu1, mu2, log = FALSE) rskellam(n, mu1, mu2)
dskellam(x, mu1, mu2, log = FALSE) rskellam(n, mu1, mu2)
x |
vector of quantiles. |
mu1 , mu2
|
positive valued parameters. |
log |
logical; if TRUE, probabilities p are given as log(p). |
n |
number of observations. If |
If and
follow Poisson distributions with means
and
, than
follows
Skellam distribution parametrized by
and
.
Probability mass function
Karlis, D., & Ntzoufras, I. (2006). Bayesian analysis of the differences of count data. Statistics in medicine, 25(11), 1885-1905.
Skellam, J.G. (1946). The frequency distribution of the difference between two Poisson variates belonging to different populations. Journal of the Royal Statistical Society, series A, 109(3), 26.
x <- rskellam(1e5, 5, 13) xx <- -40:40 plot(prop.table(table(x)), type = "h") lines(xx, dskellam(xx, 5, 13), col = "red")
x <- rskellam(1e5, 5, 13) xx <- -40:40 plot(prop.table(table(x)), type = "h") lines(xx, dskellam(xx, 5, 13), col = "red")
Probability mass function, distribution function and random generation for slash distribution.
dslash(x, mu = 0, sigma = 1, log = FALSE) pslash(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rslash(n, mu = 0, sigma = 1)
dslash(x, mu = 0, sigma = 1, log = FALSE) pslash(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rslash(n, mu = 0, sigma = 1)
x , q
|
vector of quantiles. |
mu |
vector of locations |
sigma |
vector of positive valued scale parameters. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
If and
,
then
follows slash distribution.
Probability density function
Cumulative distribution function
x <- rslash(1e5, 5, 3) hist(x, 1e5, freq = FALSE, xlim = c(-100, 100)) curve(dslash(x, 5, 3), -100, 100, col = "red", n = 500, add = TRUE) hist(pslash(x, 5, 3)) plot(ecdf(x), xlim = c(-100, 100)) curve(pslash(x, 5, 3), -100, 100, col = "red", lwd = 2, n = 500, add = TRUE)
x <- rslash(1e5, 5, 3) hist(x, 1e5, freq = FALSE, xlim = c(-100, 100)) curve(dslash(x, 5, 3), -100, 100, col = "red", n = 500, add = TRUE) hist(pslash(x, 5, 3)) plot(ecdf(x), xlim = c(-100, 100)) curve(pslash(x, 5, 3), -100, 100, col = "red", lwd = 2, n = 500, add = TRUE)
Density, distribution function, quantile function and random generation for the triangular distribution.
dtriang(x, a = -1, b = 1, c = (a + b)/2, log = FALSE) ptriang(q, a = -1, b = 1, c = (a + b)/2, lower.tail = TRUE, log.p = FALSE) qtriang(p, a = -1, b = 1, c = (a + b)/2, lower.tail = TRUE, log.p = FALSE) rtriang(n, a = -1, b = 1, c = (a + b)/2)
dtriang(x, a = -1, b = 1, c = (a + b)/2, log = FALSE) ptriang(q, a = -1, b = 1, c = (a + b)/2, lower.tail = TRUE, log.p = FALSE) qtriang(p, a = -1, b = 1, c = (a + b)/2, lower.tail = TRUE, log.p = FALSE) rtriang(n, a = -1, b = 1, c = (a + b)/2)
x , q
|
vector of quantiles. |
a , b , c
|
minimum, maximum and mode of the distribution. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
For random generation MINMAX method described by Stein and Keblis (2009) is used.
Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). Statistical Distributions. John Wiley & Sons.
Stein, W. E., & Keblis, M. F. (2009). A new method to simulate the triangular distribution. Mathematical and computer modelling, 49(5), 1143-1147.
x <- rtriang(1e5, 5, 7, 6) hist(x, 100, freq = FALSE) curve(dtriang(x, 5, 7, 6), 3, 10, n = 500, col = "red", add = TRUE) hist(ptriang(x, 5, 7, 6)) plot(ecdf(x)) curve(ptriang(x, 5, 7, 6), 3, 10, n = 500, col = "red", lwd = 2, add = TRUE)
x <- rtriang(1e5, 5, 7, 6) hist(x, 100, freq = FALSE) curve(dtriang(x, 5, 7, 6), 3, 10, n = 500, col = "red", add = TRUE) hist(ptriang(x, 5, 7, 6)) plot(ecdf(x)) curve(ptriang(x, 5, 7, 6), 3, 10, n = 500, col = "red", lwd = 2, add = TRUE)
Density, distribution function, quantile function and random generation for the truncated binomial distribution.
dtbinom(x, size, prob, a = -Inf, b = Inf, log = FALSE) ptbinom(q, size, prob, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) qtbinom(p, size, prob, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) rtbinom(n, size, prob, a = -Inf, b = Inf)
dtbinom(x, size, prob, a = -Inf, b = Inf, log = FALSE) ptbinom(q, size, prob, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) qtbinom(p, size, prob, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) rtbinom(n, size, prob, a = -Inf, b = Inf)
x , q
|
vector of quantiles. |
size |
number of trials (zero or more). |
prob |
probability of success on each trial. |
a , b
|
lower and upper truncation points ( |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
x <- rtbinom(1e5, 100, 0.83, 76, 86) xx <- seq(0, 100) plot(prop.table(table(x))) lines(xx, dtbinom(xx, 100, 0.83, 76, 86), col = "red") hist(ptbinom(x, 100, 0.83, 76, 86)) xx <- seq(0, 100, by = 0.01) plot(ecdf(x)) lines(xx, ptbinom(xx, 100, 0.83, 76, 86), col = "red", lwd = 2) uu <- seq(0, 1, by = 0.001) lines(qtbinom(uu, 100, 0.83, 76, 86), uu, col = "blue", lty = 2)
x <- rtbinom(1e5, 100, 0.83, 76, 86) xx <- seq(0, 100) plot(prop.table(table(x))) lines(xx, dtbinom(xx, 100, 0.83, 76, 86), col = "red") hist(ptbinom(x, 100, 0.83, 76, 86)) xx <- seq(0, 100, by = 0.01) plot(ecdf(x)) lines(xx, ptbinom(xx, 100, 0.83, 76, 86), col = "red", lwd = 2) uu <- seq(0, 1, by = 0.001) lines(qtbinom(uu, 100, 0.83, 76, 86), uu, col = "blue", lty = 2)
Density, distribution function, quantile function and random generation for the truncated normal distribution.
dtnorm(x, mean = 0, sd = 1, a = -Inf, b = Inf, log = FALSE) ptnorm( q, mean = 0, sd = 1, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE ) qtnorm( p, mean = 0, sd = 1, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE ) rtnorm(n, mean = 0, sd = 1, a = -Inf, b = Inf)
dtnorm(x, mean = 0, sd = 1, a = -Inf, b = Inf, log = FALSE) ptnorm( q, mean = 0, sd = 1, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE ) qtnorm( p, mean = 0, sd = 1, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE ) rtnorm(n, mean = 0, sd = 1, a = -Inf, b = Inf)
x , q
|
vector of quantiles. |
mean , sd
|
location and scale parameters. Scale must be positive. |
a , b
|
lower and upper truncation points ( |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
Cumulative distribution function
Quantile function
For random generation algorithm described by Robert (1995) is used.
Robert, C.P. (1995). Simulation of truncated normal variables. Statistics and Computing 5(2): 121-125. https://arxiv.org/abs/0907.4010
Burkardt, J. (17 October 2014). The Truncated Normal Distribution. Florida State University. https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf
x <- rtnorm(1e5, 5, 3, b = 7) hist(x, 100, freq = FALSE) curve(dtnorm(x, 5, 3, b = 7), -8, 8, col = "red", add = TRUE) hist(ptnorm(x, 5, 3, b = 7)) plot(ecdf(x)) curve(ptnorm(x, 5, 3, b = 7), -8, 8, col = "red", lwd = 2, add = TRUE) R <- 1e5 partmp <- par(mfrow = c(2,4), mar = c(2,2,2,2)) hist(rtnorm(R), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x), -5, 5, col = "red", add = TRUE) hist(rtnorm(R, a = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = 0), -1, 5, col = "red", add = TRUE) hist(rtnorm(R, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, b = 0), -5, 5, col = "red", add = TRUE) hist(rtnorm(R, a = 0, b = 1), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = 0, b = 1), -1, 2, col = "red", add = TRUE) hist(rtnorm(R, a = -1, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = -1, b = 0), -2, 2, col = "red", add = TRUE) hist(rtnorm(R, mean = -6, a = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, mean = -6, a = 0), -2, 1, col = "red", add = TRUE) hist(rtnorm(R, mean = 8, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, mean = 8, b = 0), -2, 1, col = "red", add = TRUE) hist(rtnorm(R, a = 3, b = 5), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = 3, b = 5), 2, 5, col = "red", add = TRUE) par(partmp)
x <- rtnorm(1e5, 5, 3, b = 7) hist(x, 100, freq = FALSE) curve(dtnorm(x, 5, 3, b = 7), -8, 8, col = "red", add = TRUE) hist(ptnorm(x, 5, 3, b = 7)) plot(ecdf(x)) curve(ptnorm(x, 5, 3, b = 7), -8, 8, col = "red", lwd = 2, add = TRUE) R <- 1e5 partmp <- par(mfrow = c(2,4), mar = c(2,2,2,2)) hist(rtnorm(R), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x), -5, 5, col = "red", add = TRUE) hist(rtnorm(R, a = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = 0), -1, 5, col = "red", add = TRUE) hist(rtnorm(R, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, b = 0), -5, 5, col = "red", add = TRUE) hist(rtnorm(R, a = 0, b = 1), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = 0, b = 1), -1, 2, col = "red", add = TRUE) hist(rtnorm(R, a = -1, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = -1, b = 0), -2, 2, col = "red", add = TRUE) hist(rtnorm(R, mean = -6, a = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, mean = -6, a = 0), -2, 1, col = "red", add = TRUE) hist(rtnorm(R, mean = 8, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, mean = 8, b = 0), -2, 1, col = "red", add = TRUE) hist(rtnorm(R, a = 3, b = 5), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = 3, b = 5), 2, 5, col = "red", add = TRUE) par(partmp)
Density, distribution function, quantile function and random generation for the truncated Poisson distribution.
dtpois(x, lambda, a = -Inf, b = Inf, log = FALSE) ptpois(q, lambda, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) qtpois(p, lambda, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) rtpois(n, lambda, a = -Inf, b = Inf)
dtpois(x, lambda, a = -Inf, b = Inf, log = FALSE) ptpois(q, lambda, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) qtpois(p, lambda, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) rtpois(n, lambda, a = -Inf, b = Inf)
x , q
|
vector of quantiles. |
lambda |
vector of (non-negative) means. |
a , b
|
lower and upper truncation points ( |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Plackett, R.L. (1953). The truncated Poisson distribution. Biometrics, 9(4), 485-488.
Singh, J. (1978). A characterization of positive Poisson distribution and its statistical application. SIAM Journal on Applied Mathematics, 34(3), 545-548.
Dalgaard, P. (May 1, 2005). [R] simulate zero-truncated Poisson distribution. R-help mailing list. https://stat.ethz.ch/pipermail/r-help/2005-May/070680.html
x <- rtpois(1e5, 14, 16) xx <- seq(-1, 50) plot(prop.table(table(x))) lines(xx, dtpois(xx, 14, 16), col = "red") hist(ptpois(x, 14, 16)) xx <- seq(0, 50, by = 0.01) plot(ecdf(x)) lines(xx, ptpois(xx, 14, 16), col = "red", lwd = 2) uu <- seq(0, 1, by = 0.001) lines(qtpois(uu, 14, 16), uu, col = "blue", lty = 2) # Zero-truncated Poisson x <- rtpois(1e5, 5, 0) xx <- seq(-1, 50) plot(prop.table(table(x))) lines(xx, dtpois(xx, 5, 0), col = "red") hist(ptpois(x, 5, 0)) xx <- seq(0, 50, by = 0.01) plot(ecdf(x)) lines(xx, ptpois(xx, 5, 0), col = "red", lwd = 2) lines(qtpois(uu, 5, 0), uu, col = "blue", lty = 2)
x <- rtpois(1e5, 14, 16) xx <- seq(-1, 50) plot(prop.table(table(x))) lines(xx, dtpois(xx, 14, 16), col = "red") hist(ptpois(x, 14, 16)) xx <- seq(0, 50, by = 0.01) plot(ecdf(x)) lines(xx, ptpois(xx, 14, 16), col = "red", lwd = 2) uu <- seq(0, 1, by = 0.001) lines(qtpois(uu, 14, 16), uu, col = "blue", lty = 2) # Zero-truncated Poisson x <- rtpois(1e5, 5, 0) xx <- seq(-1, 50) plot(prop.table(table(x))) lines(xx, dtpois(xx, 5, 0), col = "red") hist(ptpois(x, 5, 0)) xx <- seq(0, 50, by = 0.01) plot(ecdf(x)) lines(xx, ptpois(xx, 5, 0), col = "red", lwd = 2) lines(qtpois(uu, 5, 0), uu, col = "blue", lty = 2)
Quantile function, and random generation for the Tukey lambda distribution.
qtlambda(p, lambda, lower.tail = TRUE, log.p = FALSE) rtlambda(n, lambda)
qtlambda(p, lambda, lower.tail = TRUE, log.p = FALSE) rtlambda(n, lambda)
p |
vector of probabilities. |
lambda |
shape parameter. |
lower.tail |
logical; if TRUE (default), probabilities are |
log.p |
logical; if TRUE, probabilities p are given as log(p). |
n |
number of observations. If |
Tukey lambda distribution is a continuous probability distribution defined in terms of its quantile function. It is typically used to identify other distributions.
Quantile function:
Joiner, B.L., & Rosenblatt, J.R. (1971). Some properties of the range in samples from Tukey's symmetric lambda distributions. Journal of the American Statistical Association, 66(334), 394-399.
Hastings Jr, C., Mosteller, F., Tukey, J.W., & Winsor, C.P. (1947). Low moments for small samples: a comparative study of order statistics. The Annals of Mathematical Statistics, 413-426.
pp = seq(0, 1, by = 0.001) partmp <- par(mfrow = c(2,3)) plot(qtlambda(pp, -1), pp, type = "l", main = "lambda = -1 (Cauchy)") plot(qtlambda(pp, 0), pp, type = "l", main = "lambda = 0 (logistic)") plot(qtlambda(pp, 0.14), pp, type = "l", main = "lambda = 0.14 (normal)") plot(qtlambda(pp, 0.5), pp, type = "l", main = "lambda = 0.5 (concave)") plot(qtlambda(pp, 1), pp, type = "l", main = "lambda = 1 (uniform)") plot(qtlambda(pp, 2), pp, type = "l", main = "lambda = 2 (uniform)") hist(rtlambda(1e5, -1), freq = FALSE, main = "lambda = -1 (Cauchy)") hist(rtlambda(1e5, 0), freq = FALSE, main = "lambda = 0 (logistic)") hist(rtlambda(1e5, 0.14), freq = FALSE, main = "lambda = 0.14 (normal)") hist(rtlambda(1e5, 0.5), freq = FALSE, main = "lambda = 0.5 (concave)") hist(rtlambda(1e5, 1), freq = FALSE, main = "lambda = 1 (uniform)") hist(rtlambda(1e5, 2), freq = FALSE, main = "lambda = 2 (uniform)") par(partmp)
pp = seq(0, 1, by = 0.001) partmp <- par(mfrow = c(2,3)) plot(qtlambda(pp, -1), pp, type = "l", main = "lambda = -1 (Cauchy)") plot(qtlambda(pp, 0), pp, type = "l", main = "lambda = 0 (logistic)") plot(qtlambda(pp, 0.14), pp, type = "l", main = "lambda = 0.14 (normal)") plot(qtlambda(pp, 0.5), pp, type = "l", main = "lambda = 0.5 (concave)") plot(qtlambda(pp, 1), pp, type = "l", main = "lambda = 1 (uniform)") plot(qtlambda(pp, 2), pp, type = "l", main = "lambda = 2 (uniform)") hist(rtlambda(1e5, -1), freq = FALSE, main = "lambda = -1 (Cauchy)") hist(rtlambda(1e5, 0), freq = FALSE, main = "lambda = 0 (logistic)") hist(rtlambda(1e5, 0.14), freq = FALSE, main = "lambda = 0.14 (normal)") hist(rtlambda(1e5, 0.5), freq = FALSE, main = "lambda = 0.5 (concave)") hist(rtlambda(1e5, 1), freq = FALSE, main = "lambda = 1 (uniform)") hist(rtlambda(1e5, 2), freq = FALSE, main = "lambda = 2 (uniform)") par(partmp)
Density, distribution function and random generation for the Wald distribution.
dwald(x, mu, lambda, log = FALSE) pwald(q, mu, lambda, lower.tail = TRUE, log.p = FALSE) rwald(n, mu, lambda)
dwald(x, mu, lambda, log = FALSE) pwald(q, mu, lambda, lower.tail = TRUE, log.p = FALSE) rwald(n, mu, lambda)
x , q
|
vector of quantiles. |
mu , lambda
|
location and shape parameters. Scale must be positive. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
n |
number of observations. If |
p |
vector of probabilities. |
Probability density function
Cumulative distribution function
Random generation is done using the algorithm described by Michael, Schucany and Haas (1976).
Michael, J.R., Schucany, W.R., and Haas, R.W. (1976). Generating Random Variates Using Transformations with Multiple Roots. The American Statistician, 30(2): 88-90.
x <- rwald(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dwald(x, 5, 16), 0, 50, col = "red", add = TRUE) hist(pwald(x, 5, 16)) plot(ecdf(x)) curve(pwald(x, 5, 16), 0, 50, col = "red", lwd = 2, add = TRUE)
x <- rwald(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dwald(x, 5, 16), 0, 50, col = "red", add = TRUE) hist(pwald(x, 5, 16)) plot(ecdf(x)) curve(pwald(x, 5, 16), 0, 50, col = "red", lwd = 2, add = TRUE)
Probability mass function and random generation for the zero-inflated binomial distribution.
dzib(x, size, prob, pi, log = FALSE) pzib(q, size, prob, pi, lower.tail = TRUE, log.p = FALSE) qzib(p, size, prob, pi, lower.tail = TRUE, log.p = FALSE) rzib(n, size, prob, pi)
dzib(x, size, prob, pi, log = FALSE) pzib(q, size, prob, pi, lower.tail = TRUE, log.p = FALSE) qzib(p, size, prob, pi, lower.tail = TRUE, log.p = FALSE) rzib(n, size, prob, pi)
x , q
|
vector of quantiles. |
size |
number of trials (zero or more). |
prob |
probability of success in each trial. |
pi |
probability of extra zeros. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
x <- rzib(1e5, 10, 0.6, 0.33) xx <- -2:20 plot(prop.table(table(x)), type = "h") lines(xx, dzib(xx, 10, 0.6, 0.33), col = "red") xx <- seq(0, 20, by = 0.01) plot(ecdf(x)) lines(xx, pzib(xx, 10, 0.6, 0.33), col = "red")
x <- rzib(1e5, 10, 0.6, 0.33) xx <- -2:20 plot(prop.table(table(x)), type = "h") lines(xx, dzib(xx, 10, 0.6, 0.33), col = "red") xx <- seq(0, 20, by = 0.01) plot(ecdf(x)) lines(xx, pzib(xx, 10, 0.6, 0.33), col = "red")
Probability mass function and random generation for the zero-inflated negative binomial distribution.
dzinb(x, size, prob, pi, log = FALSE) pzinb(q, size, prob, pi, lower.tail = TRUE, log.p = FALSE) qzinb(p, size, prob, pi, lower.tail = TRUE, log.p = FALSE) rzinb(n, size, prob, pi)
dzinb(x, size, prob, pi, log = FALSE) pzinb(q, size, prob, pi, lower.tail = TRUE, log.p = FALSE) qzinb(p, size, prob, pi, lower.tail = TRUE, log.p = FALSE) rzinb(n, size, prob, pi)
x , q
|
vector of quantiles. |
size |
target for number of successful trials, or dispersion parameter (the shape parameter of the gamma mixing distribution). Must be strictly positive, need not be integer. |
prob |
probability of success in each trial. |
pi |
probability of extra zeros. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
x <- rzinb(1e5, 100, 0.6, 0.33) xx <- -2:200 plot(prop.table(table(x)), type = "h") lines(xx, dzinb(xx, 100, 0.6, 0.33), col = "red") xx <- seq(0, 200, by = 0.01) plot(ecdf(x)) lines(xx, pzinb(xx, 100, 0.6, 0.33), col = "red")
x <- rzinb(1e5, 100, 0.6, 0.33) xx <- -2:200 plot(prop.table(table(x)), type = "h") lines(xx, dzinb(xx, 100, 0.6, 0.33), col = "red") xx <- seq(0, 200, by = 0.01) plot(ecdf(x)) lines(xx, pzinb(xx, 100, 0.6, 0.33), col = "red")
Probability mass function and random generation for the zero-inflated Poisson distribution.
dzip(x, lambda, pi, log = FALSE) pzip(q, lambda, pi, lower.tail = TRUE, log.p = FALSE) qzip(p, lambda, pi, lower.tail = TRUE, log.p = FALSE) rzip(n, lambda, pi)
dzip(x, lambda, pi, log = FALSE) pzip(q, lambda, pi, lower.tail = TRUE, log.p = FALSE) qzip(p, lambda, pi, lower.tail = TRUE, log.p = FALSE) rzip(n, lambda, pi)
x , q
|
vector of quantiles. |
lambda |
vector of (non-negative) means. |
pi |
probability of extra zeros. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
x <- rzip(1e5, 6, 0.33) xx <- -2:20 plot(prop.table(table(x)), type = "h") lines(xx, dzip(xx, 6, 0.33), col = "red") xx <- seq(0, 20, by = 0.01) plot(ecdf(x)) lines(xx, pzip(xx, 6, 0.33), col = "red")
x <- rzip(1e5, 6, 0.33) xx <- -2:20 plot(prop.table(table(x)), type = "h") lines(xx, dzip(xx, 6, 0.33), col = "red") xx <- seq(0, 20, by = 0.01) plot(ecdf(x)) lines(xx, pzip(xx, 6, 0.33), col = "red")