diff --git a/src/lib/Chart.re b/src/lib/Chart.re new file mode 100644 index 00000000..439928e7 --- /dev/null +++ b/src/lib/Chart.re @@ -0,0 +1,20 @@ +[@react.component] +let make = + ( + ~data, + ~minX=None, + ~maxX=None, + ~width=300, + ~height=50, + ~color=`hex("7e9db7"), + ) => + ; \ No newline at end of file diff --git a/src/lib/Prop.re b/src/lib/Prop.re index bc238c6b..21c5f922 100644 --- a/src/lib/Prop.re +++ b/src/lib/Prop.re @@ -40,10 +40,7 @@ module Value = { let cdf: Types.distribution = CdfLibrary.Distribution.fromString(r, 2000); <> - + CdfLibrary.Distribution.toPdf |> Types.toJs} /> {r |> ReasonReact.string} ; | Probability(r) => diff --git a/src/lib/Types.re b/src/lib/Types.re index ea323b11..fb7ace63 100644 --- a/src/lib/Types.re +++ b/src/lib/Types.re @@ -3,6 +3,10 @@ type distribution = { ys: array(float), }; +let toJs = (t: distribution) => { + {"xs": t.xs, "ys": t.ys}; +}; + let toComponentsDist = (d: distribution): ForetoldComponents.Types.Dist.t => { xs: d.xs, ys: d.ys, @@ -14,4 +18,37 @@ type cdf = distribution; let foo = (b: pdf) => 3.9; let bar: cdf = {xs: [||], ys: [||]}; -let cc = foo(bar); \ No newline at end of file +let cc = foo(bar); + +module LimitedDomainCdf = { + type t = { + distribution, + domainMaxX: float, + }; + + let fromCdf = (cdf: cdf, domainMaxX: float, probabilityAtMaxX: float) => { + let distribution: 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/utility/GuesstimatorLibrary.js b/src/utility/GuesstimatorLibrary.js index 55f12894..345ceb77 100644 --- a/src/utility/GuesstimatorLibrary.js +++ b/src/utility/GuesstimatorLibrary.js @@ -44,7 +44,6 @@ const toPdf = (values, sampleCount, min, max) => { }; let run = (text, sampleCount, inputs=[], min=false, max=false) => { - console.log(text); let [_error, item] = Guesstimator.parse({ text: "=" + text }); const { parsedInput } = item; const { guesstimateType } = parsedInput;