DistFunctor -> Distributions
This commit is contained in:
parent
7f0ab442ad
commit
6a57095cad
|
@ -9,9 +9,7 @@ let shape: DistributionTypes.xyShape = {
|
||||||
let step: DistributionTypes.xyShape = {
|
let step: DistributionTypes.xyShape = {
|
||||||
xs: [|1., 4., 8.|],
|
xs: [|1., 4., 8.|],
|
||||||
ys: [|8., 17., 19.|],
|
ys: [|8., 17., 19.|],
|
||||||
};
|
} /* }*/;
|
||||||
|
|
||||||
open Shape /* )*/;
|
|
||||||
|
|
||||||
// describe("Shape", () =>
|
// describe("Shape", () =>
|
||||||
// describe("XYShape", () => {
|
// describe("XYShape", () => {
|
||||||
|
@ -20,5 +18,4 @@ open Shape /* )*/;
|
||||||
// );
|
// );
|
||||||
// test("#yFOo", () =>
|
// test("#yFOo", () =>
|
||||||
// expect(Discrete.integrate(shape)) |> toEqual(step)
|
// expect(Discrete.integrate(shape)) |> toEqual(step)
|
||||||
// );
|
// );
|
||||||
// })
|
|
|
@ -1,10 +1,12 @@
|
||||||
module DistPlusChart = {
|
module DistPlusChart = {
|
||||||
[@react.component]
|
[@react.component]
|
||||||
let make = (~distPlus: DistributionTypes.distPlus, ~onHover) => {
|
let make = (~distPlus: DistributionTypes.distPlus, ~onHover) => {
|
||||||
open DistFunctor.DistPlus;
|
open Distributions.DistPlus;
|
||||||
let discrete = distPlus |> T.toDiscrete;
|
let discrete = distPlus |> T.toDiscrete;
|
||||||
let continuous =
|
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 minX = T.minX(distPlus);
|
||||||
let maxX = T.maxX(distPlus);
|
let maxX = T.maxX(distPlus);
|
||||||
let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
|
let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
|
||||||
|
@ -23,13 +25,14 @@ module DistPlusChart = {
|
||||||
module IntegralChart = {
|
module IntegralChart = {
|
||||||
[@react.component]
|
[@react.component]
|
||||||
let make = (~distPlus: DistributionTypes.distPlus, ~onHover) => {
|
let make = (~distPlus: DistributionTypes.distPlus, ~onHover) => {
|
||||||
open DistFunctor.DistPlus;
|
open Distributions.DistPlus;
|
||||||
let integral = DistFunctor.DistPlus.T.Integral.get(~cache=None, distPlus);
|
let integral =
|
||||||
|
Distributions.DistPlus.T.Integral.get(~cache=None, distPlus);
|
||||||
let continuous =
|
let continuous =
|
||||||
integral
|
integral
|
||||||
|> T.toContinuous
|
|> T.toContinuous
|
||||||
|> E.O.fmap(DistFunctor.Continuous.toLinear)
|
|> E.O.fmap(Distributions.Continuous.toLinear)
|
||||||
|> E.O.fmap(DistFunctor.Continuous.getShape);
|
|> E.O.fmap(Distributions.Continuous.getShape);
|
||||||
let minX = T.minX(integral);
|
let minX = T.minX(integral);
|
||||||
let maxX = T.maxX(integral);
|
let maxX = T.maxX(integral);
|
||||||
let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
|
let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
|
||||||
|
@ -76,7 +79,7 @@ let make = (~distPlus: DistributionTypes.distPlus) => {
|
||||||
</th>
|
</th>
|
||||||
<th className="px-4 py-2 border ">
|
<th className="px-4 py-2 border ">
|
||||||
{distPlus
|
{distPlus
|
||||||
|> DistFunctor.DistPlus.T.Integral.xToY(~cache=None, x)
|
|> Distributions.DistPlus.T.Integral.xToY(~cache=None, x)
|
||||||
|> E.Float.with2DigitsPrecision
|
|> E.Float.with2DigitsPrecision
|
||||||
|> ReasonReact.string}
|
|> ReasonReact.string}
|
||||||
</th>
|
</th>
|
||||||
|
|
|
@ -15,10 +15,10 @@ let toDistPlus = (~sampleCount, t: distPlusIngredients) => {
|
||||||
~sampleCount,
|
~sampleCount,
|
||||||
(),
|
(),
|
||||||
)
|
)
|
||||||
|> E.O.bind(_, DistFunctor.Mixed.clean);
|
|> E.O.bind(_, Distributions.Mixed.clean);
|
||||||
shape
|
shape
|
||||||
|> E.O.fmap(shape =>
|
|> E.O.fmap(shape =>
|
||||||
DistFunctor.DistPlus.make(
|
Distributions.DistPlus.make(
|
||||||
~shape,
|
~shape,
|
||||||
~domain=t.domain,
|
~domain=t.domain,
|
||||||
~unit=t.unit,
|
~unit=t.unit,
|
||||||
|
|
|
@ -456,7 +456,6 @@ module DistPlus = {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// todo: adjust for limit, and the fact that total mass is lower.
|
|
||||||
let xToY = (f, t: t) =>
|
let xToY = (f, t: t) =>
|
||||||
t
|
t
|
||||||
|> toShape
|
|> toShape
|
|
@ -17,7 +17,7 @@ let build = (~continuous, ~discrete, ~assumptions) =>
|
||||||
} =>
|
} =>
|
||||||
// TODO: Fix this, it's wrong :(
|
// TODO: Fix this, it's wrong :(
|
||||||
Some(
|
Some(
|
||||||
DistFunctor.Mixed.make(
|
Distributions.Mixed.make(
|
||||||
~continuous,
|
~continuous,
|
||||||
~discrete,
|
~discrete,
|
||||||
~discreteProbabilityMassFraction=r,
|
~discreteProbabilityMassFraction=r,
|
||||||
|
@ -30,7 +30,7 @@ let build = (~continuous, ~discrete, ~assumptions) =>
|
||||||
discreteProbabilityMass: Some(r),
|
discreteProbabilityMass: Some(r),
|
||||||
} =>
|
} =>
|
||||||
Some(
|
Some(
|
||||||
DistFunctor.Mixed.make(
|
Distributions.Mixed.make(
|
||||||
~continuous,
|
~continuous,
|
||||||
~discrete,
|
~discrete,
|
||||||
~discreteProbabilityMassFraction=r,
|
~discreteProbabilityMassFraction=r,
|
||||||
|
@ -57,11 +57,11 @@ let build = (~continuous, ~discrete, ~assumptions) =>
|
||||||
discreteProbabilityMass: None,
|
discreteProbabilityMass: None,
|
||||||
} =>
|
} =>
|
||||||
let discreteProbabilityMassFraction =
|
let discreteProbabilityMassFraction =
|
||||||
DistFunctor.Discrete.T.Integral.sum(~cache=None, discrete);
|
Distributions.Discrete.T.Integral.sum(~cache=None, discrete);
|
||||||
let discrete =
|
let discrete =
|
||||||
DistFunctor.Discrete.T.scaleToIntegralSum(~intendedSum=1.0, discrete);
|
Distributions.Discrete.T.scaleToIntegralSum(~intendedSum=1.0, discrete);
|
||||||
Some(
|
Some(
|
||||||
DistFunctor.Mixed.make(
|
Distributions.Mixed.make(
|
||||||
~continuous,
|
~continuous,
|
||||||
~discrete,
|
~discrete,
|
||||||
~discreteProbabilityMassFraction,
|
~discreteProbabilityMassFraction,
|
||||||
|
|
|
@ -114,7 +114,7 @@ module Model = {
|
||||||
| Prop.Value.DistPlusIngredients(distPlusIngredients) =>
|
| Prop.Value.DistPlusIngredients(distPlusIngredients) =>
|
||||||
distPlusIngredients
|
distPlusIngredients
|
||||||
|> DistPlusIngredients.toDistPlus(~sampleCount=1000)
|
|> 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
|
| _ => None
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Internals = {
|
||||||
let toContinous = (r: combined) =>
|
let toContinous = (r: combined) =>
|
||||||
continuousGet(r)
|
continuousGet(r)
|
||||||
|> CdfLibrary.JS.jsToDist
|
|> CdfLibrary.JS.jsToDist
|
||||||
|> DistFunctor.Continuous.fromShape;
|
|> Distributions.Continuous.fromShape;
|
||||||
|
|
||||||
let toDiscrete = (r: combined): DistributionTypes.xyShape =>
|
let toDiscrete = (r: combined): DistributionTypes.xyShape =>
|
||||||
discreteGet(r) |> jsToDistDiscrete;
|
discreteGet(r) |> jsToDistDiscrete;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user