Skip to content

Commit

Permalink
Using Interval instead of tuples in distr.'s supports
Browse files Browse the repository at this point in the history
  • Loading branch information
valbers committed Sep 30, 2023
1 parent 6014323 commit 94716bd
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/FSharp.Stats/Distributions/Continuous/Beta.fs
Expand Up @@ -128,8 +128,8 @@ type Beta =
/// Returns the support of the exponential distribution: [0.0, 1.0).
static member Support alpha beta =
Beta.CheckParam alpha beta
(0.0, 1.0)
Interval.CreateRightOpen<float>(0.0, 1.0)

/// A string representation of the distribution.
static member ToString alpha beta =
sprintf "Beta(α = %f, β = %f)" alpha beta
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Stats/Distributions/Continuous/Chi.fs
Expand Up @@ -75,7 +75,7 @@ type Chi =
/// Returns the support of the exponential distribution: [0, Positive Infinity).
static member Support dof =
Chi.CheckParam dof
(0., System.Double.PositiveInfinity)
Interval.CreateRightOpen<float>(0.0, Double.PositiveInfinity)


/// A string representation of the distribution.
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Stats/Distributions/Continuous/F.fs
Expand Up @@ -102,7 +102,7 @@ type F =
/// Returns the support of the exponential distribution: (0., Positive Infinity).
static member Support dof1 dof2 =
F.CheckParam dof1 dof2
(0., System.Double.PositiveInfinity)
Interval.CreateRightOpen<float>(0., Double.PositiveInfinity)

/// A string representation of the distribution.
static member ToString dof1 dof2 =
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Stats/Distributions/Continuous/Gamma.fs
Expand Up @@ -163,7 +163,7 @@ type Gamma =
/// Returns the support of the exponential distribution: [0, Positive Infinity).
static member Support alpha beta =
Gamma.CheckParam alpha beta
(0.0, System.Double.PositiveInfinity)
Interval.CreateRightOpen<float>(0.0, Double.PositiveInfinity)

/// A string representation of the distribution.
static member ToString alpha beta =
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Stats/Distributions/Continuous/LogNormal.fs
Expand Up @@ -75,7 +75,7 @@ type LogNormal =
/// Returns the support of the exponential distribution: [0, Positive Infinity).
static member Support mu sigma =
LogNormal.CheckParam mu sigma
(0., System.Double.PositiveInfinity)
Interval.CreateRightOpen<float>(0., Double.PositiveInfinity)

/// A string representation of the distribution.
static member ToString mu sigma =
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Stats/Distributions/Continuous/Normal.fs
Expand Up @@ -129,7 +129,7 @@ type Normal =
/// Returns the support of the exponential distribution: [0, Positive Infinity).
static member Support mu sigma =
Normal.CheckParam mu sigma
(System.Double.NegativeInfinity, System.Double.PositiveInfinity)
Interval.CreateRightOpen<float>(Double.NegativeInfinity, Double.PositiveInfinity)


/// A string representation of the distribution.
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Stats/Distributions/Continuous/StudentT.fs
Expand Up @@ -75,7 +75,7 @@ type StudentT =
/// Returns the support of the exponential distribution: (Negative Infinity, Positive Infinity).
static member Support mu tau dof =
StudentT.CheckParam mu tau dof
(System.Double.NegativeInfinity, System.Double.PositiveInfinity)
Interval.CreateOpen<float>(Double.NegativeInfinity, Double.PositiveInfinity)

/// A string representation of the distribution.
static member ToString mu tau dof =
Expand Down
10 changes: 6 additions & 4 deletions tests/FSharp.Stats.Tests/DistributionsContinuous.fs
Expand Up @@ -1039,21 +1039,23 @@ let FDistributionTests =
let dof2 = 25.
let testcase =
Continuous.F.Support dof1 dof2
let r_value = (0., System.Double.PositiveInfinity)
let r_value = Interval.CreateRightOpen<float>(0., System.Double.PositiveInfinity)

Expect.isTrue
((fst testcase=fst r_value) && (snd testcase=snd r_value))
((testcase.GetStart() = r_value.GetStart()) &&
( testcase.GetEnd() = r_value.GetEnd()))
"Continuous.F.Support does not return the expected Tupel"

testCase "Continuous.F.Support_infinity" <| fun () ->
let dof1 = infinity
let dof2 = infinity
let testcase =
Continuous.F.Support dof1 dof2
let r_value = (0., System.Double.PositiveInfinity)
let r_value = Interval.CreateRightOpen<float>(0., Double.PositiveInfinity)

Expect.isTrue
((fst testcase=fst r_value) && (snd testcase=snd r_value))
((testcase.GetStart() = r_value.GetStart()) &&
(testcase.GetEnd() = r_value.GetEnd()))
"Continuous.F.Support does not return the expected Tupel"


Expand Down

0 comments on commit 94716bd

Please sign in to comment.