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
{{ message }}
Repository navigation
[Feature Request] Unify Support syntax for all Distributions #222
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.
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.
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.
This is a good consistency improvement. The current state is:
Bernoulli — returns a list of supported values ([0; 1])
Hypergeometric (and several other discrete distributions) — returns a tuple (min, max)
Continuous distributions generally don't expose Support at all
The direction discussed above (use FSharp.Stats.Interval<'a>) seems right. Interval<'a> already exists in the library and represents a closed [start, end] range, which is the natural representation for a continuous support. For discrete distributions the interval would represent the integer range and callers would know the step is 1.
A concrete migration path:
Add ofTuple: ('a * 'a) -> Interval<'a> and toTuple: Interval<'a> -> ('a * 'a) helpers to Interval (discussed here).
Change all Support members to return Interval<float> (or Interval<int> for purely-integer discrete distributions).
For distributions with a single-point support (edge cases like a degenerate distribution) an Interval still works: Interval(v, v).
For distributions with non-contiguous support (e.g. Bernoulli, which only takes values {0, 1} but not 0.5) the Interval abstraction is a slight over-approximation, but it is still useful for bounding purposes and is consistent with how most statistics libraries handle this.
This is a breaking change for any code currently calling the tuple-returning Support members, so it would need a major version bump or a deprecation cycle. Flagging for maintainer awareness.
Activity
bvenn commentedon Jul 19, 2023
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.smoothdeveloper commentedon Jul 19, 2023
FSharp.Stats/src/FSharp.Stats/Intervals.fs
Lines 7 to 9 in 7de8b82
We may consider having static member (for overloads) or at least the first one:
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:
If the type is meant only for closed interval (rather than a larger set of those), maybe it is better to just name it
ClosedIntervalalso.bvenn commentedon Jul 19, 2023
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
Typeproperty that sets if the interval is closed/halfopen_right/halfopen_left/open.add interval tuple properties
github-actions commentedon Apr 24, 2026
🤖 This is an automated response from Repo Assist.
This is a good consistency improvement. The current state is:
[0; 1])(min, max)Supportat allThe direction discussed above (use
FSharp.Stats.Interval<'a>) seems right.Interval<'a>already exists in the library and represents a closed[start, end]range, which is the natural representation for a continuous support. For discrete distributions the interval would represent the integer range and callers would know the step is 1.A concrete migration path:
ofTuple: ('a * 'a) -> Interval<'a>andtoTuple: Interval<'a> -> ('a * 'a)helpers toInterval(discussed here).Supportmembers to returnInterval<float>(orInterval<int>for purely-integer discrete distributions).Intervalstill works:Interval(v, v).For distributions with non-contiguous support (e.g. Bernoulli, which only takes values
{0, 1}but not0.5) theIntervalabstraction is a slight over-approximation, but it is still useful for bounding purposes and is consistent with how most statistics libraries handle this.This is a breaking change for any code currently calling the tuple-returning
Supportmembers, so it would need a major version bump or a deprecation cycle. Flagging for maintainer awareness.