diff --git a/showcase/entries/Continuous.re b/showcase/entries/Continuous.re index 4dba4e73..1d4baeb5 100644 --- a/showcase/entries/Continuous.re +++ b/showcase/entries/Continuous.re @@ -24,7 +24,7 @@ let distributions = () =>

{"Single-Discrete" |> ReasonReact.string}

{setup( DistPlusIngredients.make( - ~guesstimatorString="mm(5 to 20, floor(normal(20,2)), [.5, .05])", + ~guesstimatorString="mm(5 to 20, floor(normal(20,2)), [.5, .5])", ~domain=Complete, (), ), diff --git a/src/components/charts/DistPlusPlot.re b/src/components/charts/DistPlusPlot.re index 4a37c99b..c7975bca 100644 --- a/src/components/charts/DistPlusPlot.re +++ b/src/components/charts/DistPlusPlot.re @@ -77,6 +77,9 @@ let make = (~distPlus: DistTypes.distPlus) => { {"Y Integral to Point" |> ReasonReact.string} + + {"Y Integral Total" |> ReasonReact.string} + @@ -104,12 +107,73 @@ let make = (~distPlus: DistTypes.distPlus) => { |> E.Float.with2DigitsPrecision |> ReasonReact.string} + + + + + + + + + + + + + + + + + + +
+ {"Y Integral Total" |> ReasonReact.string} + + {"Continuous Total" |> ReasonReact.string} + + {"Scaled Continuous Total" |> ReasonReact.string} + + {"Discrete Total" |> ReasonReact.string} + + {"Scaled Discrete Total" |> ReasonReact.string} +
{distPlus |> Distributions.DistPlus.T.Integral.sum(~cache=None) |> E.Float.with2DigitsPrecision |> ReasonReact.string} + {distPlus + |> Distributions.DistPlus.T.toContinuous + |> E.O.fmap( + Distributions.Continuous.T.Integral.sum(~cache=None), + ) + |> E.O.fmap(E.Float.with2DigitsPrecision) + |> E.O.default("") + |> ReasonReact.string} + + {distPlus + |> Distributions.DistPlus.T.toScaledContinuous + |> E.O.fmap( + Distributions.Continuous.T.Integral.sum(~cache=None), + ) + |> E.O.fmap(E.Float.with2DigitsPrecision) + |> E.O.default("") + |> ReasonReact.string} + + {distPlus + |> Distributions.DistPlus.T.toDiscrete + |> E.O.fmap(Distributions.Discrete.T.Integral.sum(~cache=None)) + |> E.O.fmap(E.Float.with2DigitsPrecision) + |> E.O.default("") + |> ReasonReact.string} + + {distPlus + |> Distributions.DistPlus.T.toScaledDiscrete + |> E.O.fmap(Distributions.Discrete.T.Integral.sum(~cache=None)) + |> E.O.fmap(E.Float.with2DigitsPrecision) + |> E.O.default("") + |> ReasonReact.string} +
diff --git a/src/distributions/Distributions.re b/src/distributions/Distributions.re index aa9851ab..61aa25fe 100644 --- a/src/distributions/Distributions.re +++ b/src/distributions/Distributions.re @@ -191,21 +191,6 @@ module Mixed = { discreteProbabilityMassFraction, }; - let clean = (t: DistTypes.mixedShape): option(DistTypes.shape) => { - switch (t) { - | { - continuous: {xyShape: {xs: [||], ys: [||]}}, - discrete: {xs: [||], ys: [||]}, - } => - None - | {continuous, discrete: {xs: [||], ys: [||]}} => - Some(Continuous(continuous)) - | {continuous: {xyShape: {xs: [||], ys: [||]}}, discrete} => - Some(Discrete(discrete)) - | shape => Some(Mixed(shape)) - }; - }; - // todo: Put into scaling module let scaleDiscreteFn = ({discreteProbabilityMassFraction}: DistTypes.mixedShape, f) => diff --git a/src/distributions/MixedShapeBuilder.re b/src/distributions/MixedShapeBuilder.re index cd4e4ca3..feab0ad6 100644 --- a/src/distributions/MixedShapeBuilder.re +++ b/src/distributions/MixedShapeBuilder.re @@ -21,16 +21,21 @@ let buildSimple = (~continuous, ~discrete): option(DistTypes.shape) => { Distributions.Discrete.T.Integral.sum(~cache=None, discrete); let discrete = Distributions.Discrete.T.scaleToIntegralSum(~intendedSum=1.0, discrete); - let foobar = + let continuous = + Distributions.Continuous.T.scaleToIntegralSum( + ~intendedSum=1.0, + continuous, + ); + let mixedDist = Distributions.Mixed.make( ~continuous, ~discrete, ~discreteProbabilityMassFraction, - ) - |> Distributions.Mixed.clean; - foobar; + ); + Some(Mixed(mixedDist)); }; }; + let build = (~continuous, ~discrete, ~assumptions) => switch (assumptions) { | {