You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the only option to get access to parameters from already initialized distribution is toString(). Of course in most cases it is not necessary to provide the parameters from a distribution because you still have access to the parameters the distribution was initialized with.
However in special cases in which an algorithm takes instances of the Distribution interface as input and e.g. fits the best fitting distribution, it may be beneficial to have access to the parameters to report them along with the optimized distribution.
Example
openFSharp.Statsletnormal=
Distributions.Continuous.Normal.Init 12.0.4letbernoulli=
Distributions.Discrete.Bernoulli.Init 0.2letfunctionThatTakesDistributionAsInput(dists:Distributions.Distribution<'a>[])(sample:float [])=
dists
|> Array.map (fun singleDistribution ->//do some stuff to assess the quality of the distribution fit to the sampleletfitQuality=13.37match singleDistribution.Parameters with| Distributions.Normal x -> printfn "The normal distribution with Mean: %.2f and StDev: %f has a fit quality of %.2f" x.Mean x.StandardDeviation fitQuality
| Distributions.Bernoulli x -> printfn "The bernoulli distribution with P: %f has a fit quality of %.2f" x.P fitQuality
|_-> failwithf "Distribution type was not expected within this function!"
fitQuality
)
functionThatTakesDistributionAsInput [|normal;bernoulli|][|0..10|]
The result would be:
The bernoulli distribution with P: 0.200000 has a fit quality of 13.37
val it: float array = [|13.37; 13.37|]```
## Solution
Add parameter types for each distribution that are summarized as `DistributionParameter` type. This type should be added to the distribution interface.
The text was updated successfully, but these errors were encountered:
Problem
Currently the only option to get access to parameters from already initialized distribution is
toString()
. Of course in most cases it is not necessary to provide the parameters from a distribution because you still have access to the parameters the distribution was initialized with.However in special cases in which an algorithm takes instances of the
Distribution
interface as input and e.g. fits the best fitting distribution, it may be beneficial to have access to the parameters to report them along with the optimized distribution.Example
The result would be:
The text was updated successfully, but these errors were encountered: