moved dists to distributions
subdir and added threither
This commit is contained in:
parent
4ebb11182f
commit
809ea9e225
|
@ -0,0 +1,33 @@
|
||||||
|
type distribution =
|
||||||
|
| SymbolicDist(SymbolicDistTypes.symbolicDist)
|
||||||
|
| PointSetDist(PointSetTypes.pointSetDist)
|
||||||
|
| SampleSetDist(SampleSet.Internals.Types.outputs)
|
||||||
|
|
||||||
|
module Distributions = {
|
||||||
|
module D = E.Threither(
|
||||||
|
{type tau = SymbolicDistTypes.symbolicDist},
|
||||||
|
{type tau = PointSetTypes.pointSetDist},
|
||||||
|
{type tau = SampleSet.Internals.Types.outputs}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type distinputs =
|
||||||
|
| Symb(SymbolicDistTypes.symbolicDist)
|
||||||
|
| PS(PointSetTypes.pointSetDist)
|
||||||
|
| SS(SampleSet.Internals.Types.outputs)
|
||||||
|
|
||||||
|
module type theDist = {
|
||||||
|
let t: distribution
|
||||||
|
}
|
||||||
|
|
||||||
|
module TheDistribution = (Thedist: theDist) => {
|
||||||
|
let t = Thedist.t
|
||||||
|
let thedistribution: distinputs = switch t {
|
||||||
|
| SymbolicDist(symbdist) => Symb(symbdist)
|
||||||
|
| PointSetDist(pointsetdist) => PS(pointsetdist)
|
||||||
|
| SampleSetDist(samplesetdist) => SS(samplesetdist)
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,8 +48,7 @@ let toPointSetDist = ({pointSetDist, _}: t) => pointSetDist;
|
||||||
|
|
||||||
let pointSetDistFn = (fn, {pointSetDist}: t) => fn(pointSetDist);
|
let pointSetDistFn = (fn, {pointSetDist}: t) => fn(pointSetDist);
|
||||||
|
|
||||||
module T =
|
module Thedist: Distributions.dist = {
|
||||||
Distributions.Dist({
|
|
||||||
type t = PointSetTypes.distPlus;
|
type t = PointSetTypes.distPlus;
|
||||||
type integral = PointSetTypes.distPlus;
|
type integral = PointSetTypes.distPlus;
|
||||||
let toPointSetDist = toPointSetDist;
|
let toPointSetDist = toPointSetDist;
|
||||||
|
@ -127,4 +126,6 @@ module T =
|
||||||
PointSetDist.T.mean(t.pointSetDist);
|
PointSetDist.T.mean(t.pointSetDist);
|
||||||
};
|
};
|
||||||
let variance = (t: t) => PointSetDist.T.variance(t.pointSetDist);
|
let variance = (t: t) => PointSetDist.T.variance(t.pointSetDist);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
module T = Distributions.Dist(Thedist);
|
|
@ -1,5 +1,6 @@
|
||||||
open SymbolicDistTypes
|
open SymbolicDistTypes
|
||||||
|
|
||||||
|
// TODO: make module enumeration in the same order as the variant enumeration in SymbolicDistTypes
|
||||||
module Normal = {
|
module Normal = {
|
||||||
type t = normal
|
type t = normal
|
||||||
let make = (mean, stdev): symbolicDist => #Normal({mean: mean, stdev: stdev})
|
let make = (mean, stdev): symbolicDist => #Normal({mean: mean, stdev: stdev})
|
|
@ -47,3 +47,13 @@ type analyticalSimplificationResult = [
|
||||||
| #Error(string)
|
| #Error(string)
|
||||||
| #NoSolution
|
| #NoSolution
|
||||||
]
|
]
|
||||||
|
|
||||||
|
type params =
|
||||||
|
| NormalParams(normal)
|
||||||
|
| BetaParams(beta)
|
||||||
|
| LognormalParams(lognormal)
|
||||||
|
| UniformParams(uniform)
|
||||||
|
| ExponentialParams(exponential)
|
||||||
|
| CauchyParams(cauchy)
|
||||||
|
| TriangularParams(triangular)
|
||||||
|
| FloatParams(float)
|
|
@ -441,3 +441,31 @@ module JsArray = {
|
||||||
|> Js.Array.map(Rationale.Option.toExn("Warning: This should not have happened"))
|
|> Js.Array.map(Rationale.Option.toExn("Warning: This should not have happened"))
|
||||||
let filter = Js.Array.filter
|
let filter = Js.Array.filter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module type Tau = {
|
||||||
|
type tau
|
||||||
|
}
|
||||||
|
module Threither = (Tau1: Tau, Tau2: Tau, Tau3: Tau) => {
|
||||||
|
type either3 = First(Tau1.tau) | Second(Tau2.tau) | Third(Tau3.tau)
|
||||||
|
let fmap1 = (~fn: Tau1.tau => 'a, ~x: either3) => switch x {
|
||||||
|
| First(y) => First(fn(y))
|
||||||
|
| Second(y) => Second(y)
|
||||||
|
| Third(y) => Third(y)
|
||||||
|
}
|
||||||
|
let fmap2 = (~fn: Tau2.tau => 'a, ~x: either3) => switch x {
|
||||||
|
| First(y) => First(y)
|
||||||
|
| Second(y) => Second(fn(y))
|
||||||
|
| Third(y) => Third(y)
|
||||||
|
}
|
||||||
|
let fmap3 = (~fn: Tau3.tau => 'a, ~x: either3) => switch x {
|
||||||
|
| First(y) => First(y)
|
||||||
|
| Second(y) => Second(y)
|
||||||
|
| Third(y) => Third(fn(y))
|
||||||
|
}
|
||||||
|
|
||||||
|
let trifmap = (~fn1: Tau1.tau => 'a, ~fn2: Tau2.tau => 'b, ~fn3: Tau3.tau => 'c, ~x: either3) => switch x {
|
||||||
|
| First(y) => First(fn1(y))
|
||||||
|
| Second(y) => Second(fn2(y))
|
||||||
|
| Third(y) => Third(fn3(y))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user