These are random sample generators for 22 different continuous distributions which are not readily available as Distributions
in R. Some of them are implemented in other specialized packages (i.e. rsn
in package 'sn' or rtrapezoid
in package 'trapezoid'), but here they are collated in a way that makes them easily accessible for Monte Carlo-based uncertainty propagation.
A vector with n
samples from the corresponding distribution.
Random samples can be drawn from the following distributions:
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 = 2)
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 = 0)
9) Triangular distribution: propagate:::rtriang(n, a = 0, b = 1, c = 0.5)
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)
with n
= number of samples.
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)
1) - 12), 17) - 22) use the inverse cumulative distribution function as mapping functions for runif
(Inverse Transform Method):
(1) \(U \sim \mathcal{U}(0, 1)\)
(2) \(Y = F^{-1}(U, \beta)\)
16) uses binomial selection from a \(\chi^2\)-distribution.
13) - 15), 23) employ "Rejection Sampling" using a uniform envelope distribution (Acceptance Rejection Method): (1) Find \(F_{max} = \max(F([x_{min}, x_{max}], \beta)\) (2) \(U_{max} = 1/(x_{max} - x_{min})\) (3) \(A = F_{max}/U_{max}\) (4) \(U \sim \mathcal{U}(0, 1)\) (5) \(X \sim \mathcal{U}(x_{min}, x_{max})\) (6) \(Y \iff U \le A \cdot \mathcal{U}(X, x_{min}, x_{max})/F(X, \beta)\)
These four distributions are coded in a vectorized approach and are hence not much slower than implementations in C/C++ (0.2 - 0.5 sec for 100000 samples; 3 GHz Quadcore processor, 4 GByte RAM). The code for the random generators is in file "distr-samplers.R".
Inverse CDFs were taken from: "The Ultimate Univariate Probability Distribution Explorer" http://blog.wolfram.com/data/uploads/2013/02/ProbabilityDistributionExplorer.zip.
Rejection Sampling in R: Rejection Sampling. https://www.r-bloggers.com/rejection-sampling/.
An example of rejection sampling. http://www.mas.ncl.ac.uk/~ndjw1/teaching/sim/reject/circ.html.
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).
See also propagate
, in which GUM 2008 Supplement 1 examples use these distributions.
# NOT RUN {
## First we create random samples from the
## von Mises distribution.
X <- propagate:::rmises(1000000, mu = 1, kappa = 2)
## then we fit all available distributions
## with 'fitDistr'.
fitDistr(X, nbin = 200)
## => von Mises wins! (lowest BIC)
# }
Run the code above in your browser using DataLab