DistFunctor -> Distributions

This commit is contained in:
Ozzie Gooen 2020-02-23 13:14:14 +00:00
parent 7f0ab442ad
commit 6a57095cad
8 changed files with 21 additions and 22 deletions

View File

@ -9,9 +9,7 @@ let shape: DistributionTypes.xyShape = {
let step: DistributionTypes.xyShape = {
xs: [|1., 4., 8.|],
ys: [|8., 17., 19.|],
};
open Shape /* )*/;
} /* }*/;
// describe("Shape", () =>
// describe("XYShape", () => {
@ -20,5 +18,4 @@ open Shape /* )*/;
// );
// test("#yFOo", () =>
// expect(Discrete.integrate(shape)) |> toEqual(step)
// );
// })
// );

View File

@ -1,10 +1,12 @@
module DistPlusChart = {
[@react.component]
let make = (~distPlus: DistributionTypes.distPlus, ~onHover) => {
open DistFunctor.DistPlus;
open Distributions.DistPlus;
let discrete = distPlus |> T.toDiscrete;
let continuous =
distPlus |> T.toContinuous |> E.O.fmap(DistFunctor.Continuous.getShape);
distPlus
|> T.toContinuous
|> E.O.fmap(Distributions.Continuous.getShape);
let minX = T.minX(distPlus);
let maxX = T.maxX(distPlus);
let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
@ -23,13 +25,14 @@ module DistPlusChart = {
module IntegralChart = {
[@react.component]
let make = (~distPlus: DistributionTypes.distPlus, ~onHover) => {
open DistFunctor.DistPlus;
let integral = DistFunctor.DistPlus.T.Integral.get(~cache=None, distPlus);
open Distributions.DistPlus;
let integral =
Distributions.DistPlus.T.Integral.get(~cache=None, distPlus);
let continuous =
integral
|> T.toContinuous
|> E.O.fmap(DistFunctor.Continuous.toLinear)
|> E.O.fmap(DistFunctor.Continuous.getShape);
|> E.O.fmap(Distributions.Continuous.toLinear)
|> E.O.fmap(Distributions.Continuous.getShape);
let minX = T.minX(integral);
let maxX = T.maxX(integral);
let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
@ -76,7 +79,7 @@ let make = (~distPlus: DistributionTypes.distPlus) => {
</th>
<th className="px-4 py-2 border ">
{distPlus
|> DistFunctor.DistPlus.T.Integral.xToY(~cache=None, x)
|> Distributions.DistPlus.T.Integral.xToY(~cache=None, x)
|> E.Float.with2DigitsPrecision
|> ReasonReact.string}
</th>

View File

@ -15,10 +15,10 @@ let toDistPlus = (~sampleCount, t: distPlusIngredients) => {
~sampleCount,
(),
)
|> E.O.bind(_, DistFunctor.Mixed.clean);
|> E.O.bind(_, Distributions.Mixed.clean);
shape
|> E.O.fmap(shape =>
DistFunctor.DistPlus.make(
Distributions.DistPlus.make(
~shape,
~domain=t.domain,
~unit=t.unit,

View File

@ -456,7 +456,6 @@ module DistPlus = {
);
};
// todo: adjust for limit, and the fact that total mass is lower.
let xToY = (f, t: t) =>
t
|> toShape

View File

@ -17,7 +17,7 @@ let build = (~continuous, ~discrete, ~assumptions) =>
} =>
// TODO: Fix this, it's wrong :(
Some(
DistFunctor.Mixed.make(
Distributions.Mixed.make(
~continuous,
~discrete,
~discreteProbabilityMassFraction=r,
@ -30,7 +30,7 @@ let build = (~continuous, ~discrete, ~assumptions) =>
discreteProbabilityMass: Some(r),
} =>
Some(
DistFunctor.Mixed.make(
Distributions.Mixed.make(
~continuous,
~discrete,
~discreteProbabilityMassFraction=r,
@ -57,11 +57,11 @@ let build = (~continuous, ~discrete, ~assumptions) =>
discreteProbabilityMass: None,
} =>
let discreteProbabilityMassFraction =
DistFunctor.Discrete.T.Integral.sum(~cache=None, discrete);
Distributions.Discrete.T.Integral.sum(~cache=None, discrete);
let discrete =
DistFunctor.Discrete.T.scaleToIntegralSum(~intendedSum=1.0, discrete);
Distributions.Discrete.T.scaleToIntegralSum(~intendedSum=1.0, discrete);
Some(
DistFunctor.Mixed.make(
Distributions.Mixed.make(
~continuous,
~discrete,
~discreteProbabilityMassFraction,

View File

View File

@ -114,7 +114,7 @@ module Model = {
| Prop.Value.DistPlusIngredients(distPlusIngredients) =>
distPlusIngredients
|> DistPlusIngredients.toDistPlus(~sampleCount=1000)
|> E.O.fmap(DistFunctor.DistPlus.T.Integral.xToY(~cache=None, 18.0))
|> E.O.fmap(Distributions.DistPlus.T.Integral.xToY(~cache=None, 18.0))
| _ => None
};
};

View File

@ -19,7 +19,7 @@ module Internals = {
let toContinous = (r: combined) =>
continuousGet(r)
|> CdfLibrary.JS.jsToDist
|> DistFunctor.Continuous.fromShape;
|> Distributions.Continuous.fromShape;
let toDiscrete = (r: combined): DistributionTypes.xyShape =>
discreteGet(r) |> jsToDistDiscrete;