LogNormal distribution
The LogNormal distribution can be characterized by the exponent of its parameters:
- exp(μ): the median
- exp(σ): the multiplicative standard deviation $\sigma^*$.
Function σstar
returns the multiplicative standard deviation.
A distribution can be specified by taking the log of median and $\sigma^*$
d = LogNormal(log(2), log(1.2))
σstar(d) == 1.2
Alternatively the distribution can be specified by its mean and either
- Multiplicative standard deviation,$\sigma^*$, using type
AbstractΣstar
- Standard deviation at log-scale, $\sigma$, or
- relative error, $cv$.
d = fit(LogNormal, 2, Σstar(1.2))
(mean(d), σstar(d)) == (2, 1.2)
d = fit_mean_Σ(LogNormal, 2, 1.2)
(mean(d), d.σ) == (2, 1.2)
d = fit_mean_relerror(LogNormal, 2, 0.2)
(mean(d), std(d)/mean(d)) .≈ (2, 0.2)
ScaledLogNormal: LogNormal(-x)
To support the use case of a distribution of strictly negative values, the fitting of a mirrored LogNormal on -x
is supported.
There is a type-alias ScaledLogNormal = LocationScale{T, Continuous, LogNormal{T}} where T
, denoting a scaled and shifted LogNormal distribution.
There are fitting function dispatched by this type that fit such a mirrored distribution.
d = fit_mean_Σ(ScaledLogNormal, -1, log(1.1))
(mean(d), σstar(d)) .≈ (-1.0, 1.1)
d = fit(ScaledLogNormal, -1.0, @qp_ll(-1.32), Val(:mode))
(mode(d), quantile(d, 0.025)) .≈ (-1.0, -1.32)
Note the usage of lower quantile for the mirrored distribution, here.
Detailed API
DistributionFits.σstar
— Methodσstar(d)
Get the multiplicative standard deviation of LogNormal distribution d.
Arguments
d
: The type of distribution to fit
Examples
d = LogNormal(2,log(1.2))
σstar(d) == 1.2
StatsAPI.fit
— Methodfit(D, mean, σstar::AbstractΣstar)
fit_mean_Σ(D, mean, σ::Real)
Fit a statistical distribution of type D
to mean and multiplicative standard deviation, σstar
, or scale parameter at log-scale: σ
.
Arguments
D
: The type of distribution to fitmean
: The moments of the distributionσstar::AbstractΣstar
: The multiplicative standard deviationσ
: The standard-deviation parameter at log-scale
The first version uses type AbstractΣstar
to distinguish from other methods of function fit.
Examples
d = fit(LogNormal, 2, Σstar(1.1));
(mean(d), σstar(d)) == (2, 1.1)
DistributionFits.AbstractΣstar
— TypeΣstar <: AbstractΣstar
Represent the multiplicative standard deviation of a LogNormal distribution.
Supports dispatch of fit
. Invoking the type as a function returns its single value.
Examples
a = Σstar(4.2)
a() == 4.2
DistributionFits.fit_mean_relerror
— Functionfit_mean_relerror(D, mean, relerror)
Fit a distribution of type D
to mean and relative error.
Arguments
D
: The type of distribution to fitmean
: The first moment of the distributionrelerror
: The relative error, i.e. the coefficient of variation
Examples
d = fit_mean_relerror(LogNormal, 10.0, 0.03);
(mean(d), std(d)/mean(d)) .≈ (10.0, 0.03)