Other Continuous Random Variables

Exponential

RandomVariates.expon_rngFunction
expon_rng(λ, shape=1; seed=nothing)

Generate a shape element array of random variables from a Exponential(λ) distribution. Optionally you can set a specific seed.

Notes

The pdf of an Exponential(λ) distribution is given as:

$f(x, λ) = λe^{-λx} \quad x ≥ 0$

Note

Some Exponential distributions are parameterized by $β = \frac{1}{λ}$, where λ is the number of events in an interval. In such cases, β represents the mean interarrival time; here we use λ to represent mean arrival rate per unit of time.

Examples

julia> expon_rng(3)
1-element Vector{Float64}:
 0.07033135663980515

julia> expon_rng(1.2, seed=42)
1-element Vector{Float64}:
 0.3296112244200808

julia> expon_rng(1.2, (2, 2))
2×2 Matrix{Float64}:
 1.9327    0.134739
 0.746861  0.155614

References

D.P. Kroese, T. Taimre, Z.I. Botev. Handbook of Monte Carlo Methods. Wiley Series in Probability and Statistics, John Wiley & Sons, New York, 2011.

source

Erlang

RandomVariates.erlang_rngFunction
erlang_rng(k, λ, shape=1; seed=nothing)

Generate a shape element array of random variables from a Erlang_{k}(λ) distribution. Optionally you can set a specific seed.

Notes

The pdf of an Erlang_{k}(λ) distribution is given as:

$f(x, k, λ) = \frac{λ^k e^{-λx} x^{k-1}}{(k-1)!} \quad x ≥ 0$

Examples

julia> erlang_rng(5, .5)
1-element Vector{Float64}:
 10.803989701023117

julia> erlang_rng(3, 1, (2,2))
2×2×1 Array{Float64, 3}:
[:, :, 1] =
 2.19956  4.18505
 5.46892  2.5633

References

D. Goldsman, P. Goldsman. A first course in probability and statistics. 2021.

L. Martino, D. Luengo. Extremely efficient generation of Gamma random variables for α ≥ 1. 2013.

source

Weibull

RandomVariates.weibull_rngFunction
weibull_rng(λ, β, shape=1; seed=nothing)

Generate a shape element array of random variables from a Weibull(λ, β) distribution. Optionally you can set a specific seed.

Notes

The pdf of an Weibull(λ, β) distribution is given as:

$f(x, λ, β) = λ e^{-λx^β} \quad x ≥ 0$

Examples

julia> weibull_rng(2, 2, seed=42)
1-element Vector{Float64}:
 0.31445725834527055

julia> weibull_rng(2, 2, 2)
2-element Vector{Float64}:
 0.39561285703154575
 0.6021921673483441

julia> weibull_rng(2, 2, (2,2))
2×2 Matrix{Float64}:
 0.428896  0.109897
 0.812854  0.427906
 

References

C. Alexopoulos, D. Goldsman. Random variate generation. 2020.

Law, A. Simulation modeling and analysis, 5th Ed. McGraw Hill Education, Tuscon, 2013.

source

Gamma

RandomVariates.gamma_rngFunction
gamma_rng(α, β, shape=1; seed=nothing)

Generate a shape element array of random variables from a Gamma(α, β) distribution. Optionally you can set a specific seed.

Notes

The Gamma distribution is given:

$f(x,α,β) = \frac{β^α x^{α-1} e^{-βx}}{Γ(α)} \quad x ≥ 0$

Examples

julia> gamma_rng(1,1)
1-element Vector{Float64}:
 0.5190236735858542

julia> gamma_rng(1,1,4)
4-element Vector{Float64}:
 0.3035517926878862
 0.5765419737109622
 0.44121996206333797
 0.7325887616559309

julia> gamma_rng(1,1,(2,2))
2×2 Matrix{Float64}:
 0.228818  0.88849
 0.665729  1.01668
 

References

Law, A. Simulation modeling and analysis, 5th Ed. McGraw Hill Education, Tuscon, 2013.

source

Beta

RandomVariates.beta_rngFunction
beta_rng(α, β, shape=1; seed=nothing)

Generate a shape element array of random variables from a Beta(α, β) distribution. Optionally you can set a specific seed.

Notes

The Beta distribution is given:

$f(x,α,β) = \frac{x^{α-1 (1-x)^{β-1}}}{Β(α,β)} \quad x \in [0,1]$

where $Β(α,β) = \frac{Γ(α)Γ(β)}{Γ(α+β)}$

Examples

julia> beta_rng(1,2)
1-element Vector{Float64}:
 0.44456674672905633

julia> beta_rng(1, 2, (2,2))
2×2 Matrix{Float64}:
 0.0792132  0.595657
 0.737615   0.649721

References

D.P. Kroese, T. Taimre, Z.I. Botev. Handbook of Monte Carlo Methods. Wiley Series in Probability and Statistics, John Wiley & Sons, New York, 2011.

Law, A. Simulation modeling and analysis, 5th Ed. McGraw Hill Education, Tuscon, 2013.

source

Triangular

RandomVariates.triag_rngFunction
triag_rng(a, b, m, shape=1; seed=nothing)

Generate a shape element array of random variables from a Triangular(a, b, m) distribution. Optionally you can set a specific seed.

Notes

The Triangular distribution is given by:

\[f(x, a, b, m) = \begin{cases} \frac{2(x-a)}{(m-a)(b-a)} & \text{if } a < x ≤ m, \\ \frac{2(b-x)}{(b-m)(b-a)} & \text{if } m < x ≤ c, \\ 0 & \text{otherwise} \end{cases}\]

Examples

julia> triag_rng()
1-element Vector{Float64}:
 0.3559088458688944

julia> triag_rng(0,7,2,5)
5-element Vector{Float64}:
 1.3758072115332673
 6.049452463477447
 6.042781317411027
 2.914959243260448
 4.454707036522528

References

W. Stein and M. Keblis. A new method to simulate the triangular distribution. Mathematical and Computer Modelling, Volume 49, Issues 5–6, 2009.

source