These are random sample generators for 34 continuous distributions, collated here with a consistent parameterisation for Monte Carlo-based uncertainty propagation. Most of them are not part of R's Distributions; some are implemented in other specialized packages (e.g. rsn in package 'sn' or rtrapezoid in package 'trapezoid'), and some are simple transformations of base R generators (e.g. rchi, rlnorm3, rgamma3, runorm). The functions are internal (not exported) and are therefore called with propagate:::, e.g. propagate:::rtrap(1000).
A vector with n samples from the corresponding distribution.
Andrej-Nikolai Spiess
Random samples can be drawn from the following 34 distributions (with n = number of samples):
1) Skewed-normal distribution: propagate:::rsn(n, location = 0, scale = 1, shape = 0)
2) Generalized normal distribution: propagate:::rgnorm(n, alpha = 1, xi = 1, kappa = -0.1)
3) Scaled and shifted t-distribution: propagate:::rst(n, mean = 0, sd = 1, df = 10); sd is the scale \(u\), not the standard deviation, which is \(u\sqrt{\nu/(\nu-2)}\) with \(\nu\) = df
4) Gumbel distribution: propagate:::rgumbel(n, location = 0, scale = 1)
5) Johnson SU distribution: propagate:::rJSU(n, xi = 0, lambda = 1, gamma = 1, delta = 1)
6) Johnson SB distribution: propagate:::rJSB(n, xi = 0, lambda = 1, gamma = 1, delta = 1)
7) 3P Weibull distribution: propagate:::rweibull2(n, location = 0, shape = 1, scale = 1)
8) 4P Beta distribution: propagate:::rbeta2(n, alpha1 = 1, alpha2 = 1, a = 0, b = 1)
9) Triangular distribution with mode b: propagate:::rtriang(n, a = 0, b = 0.5, c = 1)
10) Trapezoidal distribution: propagate:::rtrap(n, a = 0, b = 1, c = 2, d = 3)
11) Laplacian distribution: propagate:::rlaplace(n, mean = 0, sigma = 1)
12) Arcsine distribution: propagate:::rarcsin(n, a = 2, b = 1)
13) von Mises distribution: propagate:::rmises(n, mu = 1, kappa = 3)
14) Curvilinear Trapezoidal distribution: propagate:::rctrap(n, a = 0, b = 1, d = 0.1)
15) Generalized trapezoidal distribution:
propagate:::rgtrap(n, min = 0, mode1 = 1/3, mode2 = 2/3, max = 1, n1 = 2, n3 = 2, alpha = 1)
16) Inverse Gaussian distribution: propagate:::rinvgauss(n, mean = 1, dispersion = 1)
17) Generalized Extreme Value distribution: propagate:::rgevd(n, loc = 0, scale = 1, shape = 0)
18) Inverse Gamma distribution: propagate:::rinvgamma(n, shape = 1, scale = 5)
19) Rayleigh distribution: propagate:::rrayleigh(n, mu = 1, sigma = 1)
20) Burr distribution: propagate:::rburr(n, k = 1)
21) Chi distribution: propagate:::rchi(n, nu = 5)
22) Inverse Chi-Square distribution: propagate:::rinvchisq(n, nu = 5)
23) Cosine distribution: propagate:::rcosine(n, mu = 5, sigma = 1)
24) Pareto distribution: propagate:::rpareto(n, scale = 1, shape = 1)
25) Levy distribution: propagate:::rlevy(n, loc = 0, scale = 1)
26) Gompertz distribution: propagate:::rgompertz(n, shape = 1, rate = 1)
27) 3P log-normal distribution (Johnson SL): propagate:::rlnorm3(n, xi = 0, meanlog = 0, sdlog = 1)
28) 3P gamma distribution (Pearson type III): propagate:::rgamma3(n, xi = 0, shape = 1, rate = 1)
29) Rectangular-normal convolution: propagate:::runorm(n, a = -1, b = 1, sigma = 0.1)
30) Exponential power distribution: propagate:::rexpow(n, mu = 0, alpha = 1, beta = 2)
31) Skew-t distribution: propagate:::rskewt(n, xi = 0, omega = 1, alpha = 0, nu = 10)
32) Rice distribution: propagate:::rrice(n, nu = 1, sigma = 1)
33) Folded normal distribution: propagate:::rfnorm(n, mu = 0, sigma = 1)
34) Two-component normal mixture: propagate:::rnmix(n, p = 0.5, mu1 = -1, sd1 = 1, mu2 = 1, sd2 = 1)
Generation methods.
Inverse transform method (\(U \sim \mathcal{U}(0, 1)\), \(Y = F^{-1}(U, \beta)\)): 2), 4) - 7), 9) - 12), 15), 17), 19), 20), 24), 26). The generalized trapezoidal distribution 15) is inverted in closed form segment by segment (van Dorp & Kotz 2003).
Transformation of normal, gamma or chi-square variables: 1) (skew-normal representation \(\delta |U_0| + \sqrt{1 - \delta^2} U_1\)), 3) (\(x + u \cdot t_\nu\), scale \(u\) as in JCGM 101:2008, 6.4.9), 8) (scaled beta variable \(a + (b - a) B\)), 16) (binomial selection from a \(\chi^2\)-distribution), 18), 21), 22), 25) (\(\mu + c/Z^2\)), 27) (\(\xi + e^{\mu + \sigma Z}\)), 28) (\(\xi + G\) with \(G\) a gamma variable), 30) (\((|X - \mu|/\alpha)^\beta \sim \Gamma(1/\beta, 1)\) with random sign), 31) (skew-normal divided by \(\sqrt{\chi^2_\nu/\nu}\)), 32) (magnitude of a complex Gaussian), 33) (absolute value of a normal variable).
Convolution and mixture by construction: 29) (sum of a rectangular and a normal variable), 34) (normal variable from the first component with probability \(p\)).
Exact direct method: 14) as in JCGM 101:2008, 6.4.3.4.
Exact rejection sampling: 13) by the algorithm of Best & Fisher (1979) with a wrapped Cauchy envelope; 23) with a uniform envelope and the exact maximum of the density (acceptance rate 1/2).
The code for the random generators is in file "distr-samplers.R".
Efficient simulation of the von Mises distribution.
Best DJ, Fisher NI.
Applied Statistics (1979), 28: 152-157.
Generalized trapezoidal distributions.
van Dorp JR, Kotz S.
Metrika (2003), 58: 85-97.
The skew-normal distribution and related multivariate families.
Azzalini A.
Scandinavian Journal of Statistics (2005), 32: 159-188.
Rejection Sampling in R:
Rejection Sampling.
https://www.r-bloggers.com/2011/06/rejection-sampling/.
Rejection Sampling in general:
Non-uniform random variate generation.
Devroye L.
Springer-Verlag, New York (1986).
Distributions:
Continuous univariate distributions, Volume 1.
Johnson NL, Kotz S and Balakrishnan N.
Wiley Series in Probability and Statistics, 2.ed (2004).
propagate and makeDat, in which the JCGM 101:2008 examples use these distributions; fitDistr.
## The generators are internal: call them with 'propagate:::'.
## Trapezoidal distribution.
set.seed(123)
X1 <- propagate:::rtrap(10000, a = 0, b = 1, c = 2, d = 3)
hist(X1, breaks = 50)
## Random samples from the von Mises distribution.
set.seed(123)
X <- propagate:::rmises(2000, mu = 1, kappa = 2)
## Then we fit a selection of distributions
## (distsel = 20:25) with 'fitDistr'.
fitDistr(X, distsel = 20:25)
## => von Mises wins! (lowest BIC)
Run the code above in your browser using DataLab