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},
|
~onSubmit=({state}) => {None},
|
||||||
~initialState={
|
~initialState={
|
||||||
//guesstimatorString: "mm(normal(-10, 2), uniform(18, 25), lognormal({mean: 10, stdev: 8}), triangular(31,40,50))",
|
//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",
|
domainType: "Complete",
|
||||||
xPoint: "50.0",
|
xPoint: "50.0",
|
||||||
xPoint2: "60.0",
|
xPoint2: "60.0",
|
||||||
|
|
|
@ -248,7 +248,7 @@ module DistPlusChart = {
|
||||||
};
|
};
|
||||||
|
|
||||||
let maxX = {
|
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;
|
let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson;
|
||||||
|
|
|
@ -65,6 +65,7 @@ module T =
|
||||||
};
|
};
|
||||||
|
|
||||||
let normalize = (t: t): t => {
|
let normalize = (t: t): t => {
|
||||||
|
|
||||||
let continuousIntegralSum =
|
let continuousIntegralSum =
|
||||||
Continuous.T.Integral.sum(~cache=None, t.continuous);
|
Continuous.T.Integral.sum(~cache=None, t.continuous);
|
||||||
let discreteIntegralSum =
|
let discreteIntegralSum =
|
||||||
|
@ -76,11 +77,11 @@ module T =
|
||||||
|
|
||||||
let normalizedContinuous =
|
let normalizedContinuous =
|
||||||
t.continuous
|
t.continuous
|
||||||
|> Continuous.scaleBy(~scale=1. /. newContinuousSum)
|
|> Continuous.scaleBy(~scale=newContinuousSum /. continuousIntegralSum)
|
||||||
|> Continuous.updateKnownIntegralSum(Some(newContinuousSum));
|
|> Continuous.updateKnownIntegralSum(Some(newContinuousSum));
|
||||||
let normalizedDiscrete =
|
let normalizedDiscrete =
|
||||||
t.discrete
|
t.discrete
|
||||||
|> Discrete.scaleBy(~scale=1. /. newDiscreteSum)
|
|> Discrete.scaleBy(~scale=newDiscreteSum /. discreteIntegralSum)
|
||||||
|> Discrete.updateKnownIntegralSum(Some(newDiscreteSum));
|
|> Discrete.updateKnownIntegralSum(Some(newDiscreteSum));
|
||||||
|
|
||||||
make(~continuous=normalizedContinuous, ~discrete=normalizedDiscrete);
|
make(~continuous=normalizedContinuous, ~discrete=normalizedDiscrete);
|
||||||
|
|
|
@ -22,10 +22,6 @@ let buildSimple = (~continuous: option(DistTypes.continuousShape), ~discrete: op
|
||||||
| (0 | 1, _) => Some(Discrete(discrete))
|
| (0 | 1, _) => Some(Discrete(discrete))
|
||||||
| (_, 0) => Some(Continuous(continuous))
|
| (_, 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 =
|
let mixedDist =
|
||||||
Mixed.make(
|
Mixed.make(
|
||||||
~continuous,
|
~continuous,
|
||||||
|
|
|
@ -41,6 +41,5 @@ let run =
|
||||||
(),
|
(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
Js.log3("IS SOME?", symbolic |> E.R.toOption |> E.O.isSome, symbolic);
|
|
||||||
{symbolic: Some(symbolic), sampling};
|
{symbolic: Some(symbolic), sampling};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user