Normal Random Variables

Generating Standard Normal

RandomVariates.get_std_normalFunction
get_std_normal(shape=1; seed=nothing)

Generate a shape element array of random variables from a standard Normal(0, 1) distribution. Optionally you can set a specific seed.

Examples

julia> get_std_normal()
1-element Vector{Float64}:
 0.6315076033452351

julia> get_std_normal(5, seed=43)
5-element Vector{Float64}:
  1.2311463458421277
  1.7786409025309897
 -0.4178415161339713
  0.3518755172644067
 -0.16742990320047046

julia> get_std_normal((2,2))
2×2 Matrix{Float64}:
 -0.900365   -0.432759
 -0.0350299   1.55754
source

Normal

RandomVariates.normal_rngFunction
normal_rng(μ, σ², shape=1; seed=nothing)

Generate a shape element array of random variables from a Normal(μ, σ²) distribution. Optionally you can set a specific seed.

Notes

The Normal distribution is given by:

$f(x, μ, σ²) = \frac{1}{σ\sqrt{2π}} e^{ - \frac{1}{2} (\frac{x-μ}{σ})^2}$

Examples

julia> normal_rng()
1-element Vector{Float64}:
 0.03130435813519526

julia> normal_rng(3, 9, 2)
2-element Vector{Float64}:
  7.362935421449054
 -1.0173543995738399

julia> normal_rng(0,1,(2,2))
2×2 Matrix{Float64}:
 -0.640505   0.30303
 -0.0556832  0.714122
 

References

Walk, C. Handbook on statistical distributions for experimentalists. 2007.

source

Multivariate Normal

RandomVariates.get_mv_std_normalFunction
get_mv_std_normal(μ, Σ; seed=nothing)

Generate an array of random variables from a Multivariate Normal(μ, Σ) distribution. Optionally you can set a specific seed.

Notes

The Normal distribution is given by:

$f(\textbf{x, μ}, Σ) = \frac{1}{2π^{k/2} |Σ|^{1/2}} exp \{ - \frac{(\textbf{x} - \textbf{μ})^T Σ^{-1} (\textbf{x} - \textbf{μ})}{2} \} \quad \textbf{x} \in \mathbb{R}^k$

with mean vector $\textbf{μ} = (μ_1, μ_2, …, μ_k)$ and covariance matrix $Σ$.

Examples

julia> A
2×2 Matrix{Float64}:
 1.0  0.9
 0.9  1.0

julia> get_mv_std_normal([2,2], A)
1×2 transpose(::Vector{Float64}) with eltype Float64:
 2.60139  1.76837

julia> B
3×3 Matrix{Float64}:
 1.0  0.8  0.3
 0.8  1.0  0.6
 0.3  0.6  1.0

julia> get_mv_std_normal([0,1,2], B)
1×3 transpose(::Vector{Float64}) with eltype Float64:
 -1.24861  0.110397  0.609328
 

References

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

source
RandomVariates.mv_normal_rngFunction
mv_normal_rng(μ, Σ, shape=1; seed=nothing)

Generate a shape element array of random variables from a Multivariate Normal(μ, Σ) distribution. Optionally you can set a specific seed.

Notes

The Normal distribution is given by:

$f(\textbf{x, μ}, Σ) = \frac{1}{2π^{k/2} |Σ|^{1/2}} exp \{ - \frac{(\textbf{x} - \textbf{μ})^T Σ^{-1} (\textbf{x} - \textbf{μ})}{2} \} \quad \textbf{x} \in \mathbb{R}^k$

with mean vector $\textbf{μ} = (μ_1, μ_2, …, μ_k)$ and covariance matrix $Σ$.

Examples

julia> A
2×2 Matrix{Float64}:
 1.0  0.9
 0.9  1.0

julia> mv_normal_rng([2,2], A)
1×2 Matrix{Float64}:
 0.398043  0.651268

julia> mv_normal_rng([2,2], A, 4)
4×2 Matrix{Float64}:
 2.12004  1.9172
 4.81543  5.02956
 2.97096  2.2597
 3.27012  3.07918
 

References

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

source