FriesischScott / UncertaintyQuantification.jl

Uncertainty Quantification in Julia
MIT License
28 stars 7 forks source link

Convenience methods for distributions from mean and standard deviation #105

Closed teobros closed 7 months ago

teobros commented 1 year ago

It is more common to have the mean and standard deviation of a random quantity (e.g., obtained from experiments or data sheests) than the parameters of a distribution. Thus, it would be nice to have a function that gets the mean, standard deviation and distribution type and returns the distribution parameters in a tuple.

As a proof of concept, see the functions used to create a Gumbel and a Lognormal distribution.

function distribution_parameters(mean::Real, std::Real, d::Type{Distributions.Gumbel})
    β = std * sqrt(6) / pi
    μ = mean - MathConstants.γ * β
    return μ, β
end

function distribution_parameters(mean::Real, std::Real, d::Type{Distributions.LogNormal})
    μ = log(mean^2/sqrt(std^2+mean^2))
    σ = sqrt(log(std^2/mean^2+1))
    return μ, σ
end

Gumbel(distribution_parameters(50, 5, Gumbel)...)

LogNormal(distribution_parameters(28.8e4-19.9e4,2.64e4, LogNormal)...)