@@ -101,17 +101,20 @@ true
101101σstar (d:: LogNormal ) = exp (params (d)[2 ])
102102
103103"""
104- fit(D, mean, σstar)
104+ fit(D, mean, σstar::AbstractΣstar)
105+ fit_mean_Σ(D, mean, σ::Real)
105106
106107Fit a statistical distribution of type `D` to mean and multiplicative
107- standard deviation.
108+ standard deviation, `σstar`, or scale parameter at log-scale: `σ` .
108109
109110# Arguments
110111- `D`: The type of distribution to fit
111112- `mean`: The moments of the distribution
112113- `σstar::AbstractΣstar`: The multiplicative standard deviation
114+ - `σ`: The standard-deviation parameter at log-scale
113115
114- See also [`σstar`](@ref), [`AbstractΣstar`](@ref).
116+ The first version uses type [`AbstractΣstar`](@ref) to distinguish from
117+ other methods of function fit.
115118
116119# Examples
117120```jldoctest fm1; output = false, setup = :(using DistributionFits)
@@ -121,17 +124,23 @@ d = fit(LogNormal, 2, Σstar(1.1));
121124true
122125```
123126"""
124- function fit (:: Type{LogNormal} , mean:: T , σstar:: Abstract Σstar) where {T <: Real }
125- _T = promote_type (T, eltype (σstar))
126- fit (LogNormal{_T}, mean, σstar)
127+ function fit (d:: Type{LogNormal} , mean, σstar:: Abstract Σstar)
128+ fit_mean_Σ (d, mean, log (σstar ()))
127129end
128-
129- function fit (:: Type{LogNormal{T}} , mean:: Real , σstar:: Abstract Σstar) where {T}
130- σ = log (σstar ())
130+ function fit (d:: Type{LogNormal{T}} , mean:: Real , σstar:: Abstract Σstar) where {T}
131+ fit_mean_Σ (d, mean, log (σstar ()))
132+ end
133+ function fit_mean_Σ (:: Type{LogNormal} , mean:: T1 , σ:: T2 ) where {T1 <: Real ,T2 <: Real }
134+ _T = promote_type (T1, T2)
135+ fit_mean_Σ (LogNormal{_T}, mean, σ)
136+ end
137+ function fit_mean_Σ (:: Type{LogNormal{T}} , mean:: Real , σ:: Real ) where {T}
138+ # σ = log(σstar())
131139 μ = log (mean) - σ * σ / 2
132140 LogNormal (T (μ), T (σ))
133141end
134142
143+
135144"""
136145 fit_mean_relerror(D, mean, relerror)
137146
0 commit comments