Fix multimodals containing both discrete and continuous
This commit is contained in:
parent
fed98763d5
commit
f8060458be
|
@ -171,7 +171,7 @@ let make = () => {
|
|||
~onSubmit=({state}) => {None},
|
||||
~initialState={
|
||||
//guesstimatorString: "mm(normal(-10, 2), uniform(18, 25), lognormal({mean: 10, stdev: 8}), triangular(31,40,50))",
|
||||
guesstimatorString: "normal(0, 10) * 100", // , triangular(30, 40, 60)
|
||||
guesstimatorString: "mm(1, 2, 3, normal(2, 1))", // , triangular(30, 40, 60)
|
||||
domainType: "Complete",
|
||||
xPoint: "50.0",
|
||||
xPoint2: "60.0",
|
||||
|
|
|
@ -248,7 +248,7 @@ module DistPlusChart = {
|
|||
};
|
||||
|
||||
let maxX = {
|
||||
distPlus |> DistPlus.T.Integral.yToX(~cache=None, 0.99);
|
||||
distPlus |> DistPlus.T.Integral.yToX(~cache=None, 0.99999);
|
||||
};
|
||||
|
||||
let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson;
|
||||
|
|
|
@ -65,6 +65,7 @@ module T =
|
|||
};
|
||||
|
||||
let normalize = (t: t): t => {
|
||||
|
||||
let continuousIntegralSum =
|
||||
Continuous.T.Integral.sum(~cache=None, t.continuous);
|
||||
let discreteIntegralSum =
|
||||
|
@ -76,11 +77,11 @@ module T =
|
|||
|
||||
let normalizedContinuous =
|
||||
t.continuous
|
||||
|> Continuous.scaleBy(~scale=1. /. newContinuousSum)
|
||||
|> Continuous.scaleBy(~scale=newContinuousSum /. continuousIntegralSum)
|
||||
|> Continuous.updateKnownIntegralSum(Some(newContinuousSum));
|
||||
let normalizedDiscrete =
|
||||
t.discrete
|
||||
|> Discrete.scaleBy(~scale=1. /. newDiscreteSum)
|
||||
|> Discrete.scaleBy(~scale=newDiscreteSum /. discreteIntegralSum)
|
||||
|> Discrete.updateKnownIntegralSum(Some(newDiscreteSum));
|
||||
|
||||
make(~continuous=normalizedContinuous, ~discrete=normalizedDiscrete);
|
||||
|
|
|
@ -22,10 +22,6 @@ let buildSimple = (~continuous: option(DistTypes.continuousShape), ~discrete: op
|
|||
| (0 | 1, _) => Some(Discrete(discrete))
|
||||
| (_, 0) => Some(Continuous(continuous))
|
||||
| (_, _) =>
|
||||
let discreteProbabilityMassFraction =
|
||||
Discrete.T.Integral.sum(~cache=None, discrete);
|
||||
let discrete = Discrete.T.normalize(discrete);
|
||||
let continuous = Continuous.T.normalize(continuous);
|
||||
let mixedDist =
|
||||
Mixed.make(
|
||||
~continuous,
|
||||
|
@ -33,4 +29,4 @@ let buildSimple = (~continuous: option(DistTypes.continuousShape), ~discrete: op
|
|||
);
|
||||
Some(Mixed(mixedDist));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -41,6 +41,5 @@ let run =
|
|||
(),
|
||||
)
|
||||
};
|
||||
Js.log3("IS SOME?", symbolic |> E.R.toOption |> E.O.isSome, symbolic);
|
||||
{symbolic: Some(symbolic), sampling};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user