# Generating Random Variables

Fortuna.jl package builds its capacity to define random variables using randomvariable() wrapper function by utilizing the widely-adopted Distributions.jl package, enabling seamless integration with other probabilistic programming Julia packages such as Copulas.jl, Turing.jl and RxInfer.jl. However, unlike Distributions.jl package, Fortuna.jl package allows to define random variables not only using their parameters, but also using their moments, which often useful in the field of Structural and System Reliability Analysis.

## Defining Random Variables Using Moments

To define a random variable using its moments pass "M" as the second argument of randomvariable() function followed by the moments themselves.

# Define a lognormally distributed random variable R with
# mean (μ) of 15 and standard deviation (σ) of 10:
R = randomvariable("LogNormal", "M", [15, 10])
println("μ = $(mean(R))") println("σ =$(std(R))")
μ = 15.0
σ = 10.0

## Defining Random Variables Using Parameters

To define a random variable using its parameters pass "P" as the second argument of randomvariable() function followed by the parameters themselves.

# Define a gamma-distributed random variable Q with
# shape parameter (α) of 16 and scale parameter (θ) of 0.625:
Q = randomvariable("Gamma", "P", [16, 0.625])
println("α = $(params(Q)[1])") println("θ =$(params(Q)[2])")
α = 16.0
θ = 0.625

## Supported Random Variables

Note

If you want to define a random variable that is not supported by Fortuna.jl package, please raise an issue on the Github Issues page.

Fortuna.jl package currently supports the following distributions:

## API

Fortuna.randomvariableMethod
randomvariable(Distribution::AbstractString, DefineBy::AbstractString, Values::Union{Real, AbstractVector{<:Real}})

Function used to define random variables.