diff --git a/src/LimitedDomainCdf.re b/src/LimitedDomainCdf.re new file mode 100644 index 00000000..7a33db45 --- /dev/null +++ b/src/LimitedDomainCdf.re @@ -0,0 +1,33 @@ +type t = { + distribution: Types.distribution, + domainMaxX: float, +}; + +let fromCdf = (cdf: Types.cdf, domainMaxX: float, probabilityAtMaxX: float) => { + let distribution: Types.distribution = { + xs: cdf.xs, + ys: cdf.ys |> E.A.fmap(r => r *. probabilityAtMaxX), + }; + {distribution, domainMaxX}; +}; + +let _lastElement = (a: array('a)) => + switch (Belt.Array.size(a)) { + | 0 => None + | n => Belt.Array.get(a, n) + }; + +let probabilityBeforeDomainMax = (t: t) => _lastElement(t.distribution.ys); + +let chanceByX = (t: t) => t.distribution; + +let domainMaxX = (t: t) => t.domainMaxX; + +let probabilityDistribution = (t: t) => + t.distribution |> CdfLibrary.Distribution.toPdf; + +let probability = (t: t, xPoint: float) => + CdfLibrary.Distribution.findY(xPoint, probabilityDistribution(t)); + +let cumulativeProbability = (t: t, xPoint: float) => + CdfLibrary.Distribution.findY(xPoint, t.distribution); \ No newline at end of file diff --git a/src/lib/Prop.re b/src/lib/Prop.re index 57a77e54..bc238c6b 100644 --- a/src/lib/Prop.re +++ b/src/lib/Prop.re @@ -38,7 +38,7 @@ module Value = { | SelectSingle(r) => r |> ReasonReact.string | FloatCdf(r) => let cdf: Types.distribution = - CdfLibrary.Distribution.fromString(r, 1000); + CdfLibrary.Distribution.fromString(r, 2000); <> { xs: d.xs, ys: d.ys, -}; \ No newline at end of file +}; + +type pdf = distribution; +type cdf = distribution; + +let foo = (b: pdf) => 3.9; +let bar: cdf = {xs: [||], ys: [||]}; + +let cc = foo(bar); \ No newline at end of file