FSharp.Stats
FSharp.Stats copied to clipboard
[Feature Request] Unify `Support` syntax for all Distributions
Is your feature request related to a problem? Please describe.
The syntax for the static member Support ...
functions are written in a different syntax.
Bernoulli has a list, whereas hypergeometric returns a tuple.
https://github.com/fslaborg/FSharp.Stats/blob/262f1acf2cbeeaf008c272774d008d6d462f1022/src/FSharp.Stats/Distributions/Discrete.fs#L55-L57
https://github.com/fslaborg/FSharp.Stats/blob/262f1acf2cbeeaf008c272774d008d6d462f1022/src/FSharp.Stats/Distributions/Discrete.fs#L228-L230
Describe the solution you'd like Maybe use this issue to discuss not only unifying the syntax, but reworking it to be more intuitive and usable.
I think the best way to model the support is to use FSharp.Stats.Inverval<'a>
. Intervals support generic type inputs, therefore even multidimensional distributions would be covered.
https://github.com/fslaborg/FSharp.Stats/blob/7de8b8202a7225bf3e120a0a273243ca0555d25d/src/FSharp.Stats/Intervals.fs#L7-L9
We may consider having static member (for overloads) or at least the first one:
ofTuple: ('a * 'a) -> Interval<'a>
ofTuple: ('a * 'a) option -> Interval<'a>
Should the implementation do a comparison in case the values are swapped, and what should occur if they are?
Also, may be useful to offer the reverse:
toTuple: 'a Interval -> ('a * 'a) option
If the type is meant only for closed interval (rather than a larger set of those), maybe it is better to just name it ClosedInterval
also.
Totally agree to the ofTuple and toTuple member:+1:
I'm not sure if in any case it is allowed to have endValue < startValue. I dont't think so and therefore I would add a check that fails if the input is meaningless.
It may be an option to update the Interval type with a Type
property that sets if the interval is closed/halfopen_right/halfopen_left/open.