Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Freymaurer opened this issue Jun 24, 2022 · 3 comments
Open

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

Freymaurer opened this issue Jun 24, 2022 · 3 comments

Comments

@Freymaurer
Copy link
Contributor

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.

@bvenn
Copy link
Member

bvenn commented 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
Copy link
Contributor

smoothdeveloper commented Jul 19, 2023

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.

@bvenn
Copy link
Member

bvenn commented 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 Type property that sets if the interval is closed/halfopen_right/halfopen_left/open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants