Skip to content

[Feature Request] Unify Support syntax for all Distributions #222

Open

Description

@Freymaurer

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.

static member Support p =
bernCheckParam p
[0.0; 1.0]

static member Support N K n =
hypergeoCheckParam N K n
(0., System.Double.PositiveInfinity)

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.

Activity

  1. bvenn commented on Jul 19, 2023

    @bvenn
    Member

    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.

  2. smoothdeveloper commented on Jul 19, 2023

    @smoothdeveloper
    Contributor

    type Interval<'a> =
    | ClosedInterval of 'a * 'a
    | Empty

    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.

  3. bvenn commented on Jul 19, 2023

    @bvenn
    Member

    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.

  4. added a commit that references this issue on Jul 21, 2023
  5. github-actions commented on Apr 24, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    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:

    1. Add ofTuple: ('a * 'a) -> Interval<'a> and toTuple: Interval<'a> -> ('a * 'a) helpers to Interval (discussed here).
    2. Change all Support members to return Interval<float> (or Interval<int> for purely-integer discrete distributions).
    3. 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.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@96b9d4c39aa22359c0b38265927eadb31dcf4e2a
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions