Renames to use distPlus and distPlusIngredients
This commit is contained in:
parent
d947d43b56
commit
7f0ab442ad
|
@ -1,22 +1,18 @@
|
||||||
// "mm(floor(uniform(30,35)), normal(50,20), [.25,.5])",
|
// "mm(floor(uniform(30,35)), normal(50,20), [.25,.5])",
|
||||||
let timeDist =
|
let timeDist =
|
||||||
GenericDistribution.make(
|
DistPlusIngredients.make(
|
||||||
~generationSource=
|
~guesstimatorString="mm(floor(normal(30,2)), normal(39,1), [.5,.5])",
|
||||||
GuesstimatorString("mm(floor(normal(30,2)), normal(39,1), [.5,.5])"),
|
|
||||||
~domain=Complete,
|
~domain=Complete,
|
||||||
~unit=TimeDistribution({zero: MomentRe.momentNow(), unit: `days}),
|
~unit=TimeDistribution({zero: MomentRe.momentNow(), unit: `days}),
|
||||||
(),
|
(),
|
||||||
)
|
)
|
||||||
|> GenericDistribution.toComplexPower(~sampleCount=1000);
|
|> DistPlusIngredients.toDistPlus(~sampleCount=1000);
|
||||||
|
|
||||||
let distributions = () =>
|
let distributions = () =>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<h2> {"Basic Mixed Distribution" |> ReasonReact.string} </h2>
|
<h2> {"Basic Mixed Distribution" |> ReasonReact.string} </h2>
|
||||||
{timeDist
|
{timeDist |> E.O.React.fmapOrNull(distPlus => <DistPlusChart distPlus />)}
|
||||||
|> E.O.React.fmapOrNull(complexPower =>
|
|
||||||
<ComplexPowerChart complexPower />
|
|
||||||
)}
|
|
||||||
<h2> {"Simple Continuous" |> ReasonReact.string} </h2>
|
<h2> {"Simple Continuous" |> ReasonReact.string} </h2>
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
module ComplexPowerChart = {
|
module DistPlusChart = {
|
||||||
[@react.component]
|
[@react.component]
|
||||||
let make = (~complexPower: DistributionTypes.complexPower, ~onHover) => {
|
let make = (~distPlus: DistributionTypes.distPlus, ~onHover) => {
|
||||||
open DistFunctor.ComplexPower;
|
open DistFunctor.DistPlus;
|
||||||
let discrete = complexPower |> T.toDiscrete;
|
let discrete = distPlus |> T.toDiscrete;
|
||||||
let continuous =
|
let continuous =
|
||||||
complexPower
|
distPlus |> T.toContinuous |> E.O.fmap(DistFunctor.Continuous.getShape);
|
||||||
|> T.toContinuous
|
let minX = T.minX(distPlus);
|
||||||
|> E.O.fmap(DistFunctor.Continuous.getShape);
|
let maxX = T.maxX(distPlus);
|
||||||
let minX = T.minX(complexPower);
|
let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
|
||||||
let maxX = T.maxX(complexPower);
|
|
||||||
let timeScale =
|
|
||||||
complexPower.unit |> DistributionTypes.DistributionUnit.toJson;
|
|
||||||
<CdfChart__Plain
|
<CdfChart__Plain
|
||||||
minX
|
minX
|
||||||
maxX
|
maxX
|
||||||
|
@ -25,10 +22,9 @@ module ComplexPowerChart = {
|
||||||
|
|
||||||
module IntegralChart = {
|
module IntegralChart = {
|
||||||
[@react.component]
|
[@react.component]
|
||||||
let make = (~complexPower: DistributionTypes.complexPower, ~onHover) => {
|
let make = (~distPlus: DistributionTypes.distPlus, ~onHover) => {
|
||||||
open DistFunctor.ComplexPower;
|
open DistFunctor.DistPlus;
|
||||||
let integral =
|
let integral = DistFunctor.DistPlus.T.Integral.get(~cache=None, distPlus);
|
||||||
DistFunctor.ComplexPower.T.Integral.get(~cache=None, complexPower);
|
|
||||||
let continuous =
|
let continuous =
|
||||||
integral
|
integral
|
||||||
|> T.toContinuous
|
|> T.toContinuous
|
||||||
|
@ -36,8 +32,7 @@ module IntegralChart = {
|
||||||
|> E.O.fmap(DistFunctor.Continuous.getShape);
|
|> E.O.fmap(DistFunctor.Continuous.getShape);
|
||||||
let minX = T.minX(integral);
|
let minX = T.minX(integral);
|
||||||
let maxX = T.maxX(integral);
|
let maxX = T.maxX(integral);
|
||||||
let timeScale =
|
let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
|
||||||
complexPower.unit |> DistributionTypes.DistributionUnit.toJson;
|
|
||||||
<CdfChart__Plain
|
<CdfChart__Plain
|
||||||
minX
|
minX
|
||||||
maxX
|
maxX
|
||||||
|
@ -50,17 +45,17 @@ module IntegralChart = {
|
||||||
};
|
};
|
||||||
|
|
||||||
[@react.component]
|
[@react.component]
|
||||||
let make = (~complexPower: DistributionTypes.complexPower) => {
|
let make = (~distPlus: DistributionTypes.distPlus) => {
|
||||||
let (x, setX) = React.useState(() => 0.);
|
let (x, setX) = React.useState(() => 0.);
|
||||||
let chart =
|
let chart =
|
||||||
React.useMemo1(
|
React.useMemo1(
|
||||||
() => {<ComplexPowerChart complexPower onHover={r => {setX(_ => r)}} />},
|
() => {<DistPlusChart distPlus onHover={r => {setX(_ => r)}} />},
|
||||||
[|complexPower|],
|
[|distPlus|],
|
||||||
);
|
);
|
||||||
let chart2 =
|
let chart2 =
|
||||||
React.useMemo1(
|
React.useMemo1(
|
||||||
() => {<IntegralChart complexPower onHover={r => {setX(_ => r)}} />},
|
() => {<IntegralChart distPlus onHover={r => {setX(_ => r)}} />},
|
||||||
[|complexPower|],
|
[|distPlus|],
|
||||||
);
|
);
|
||||||
<div>
|
<div>
|
||||||
chart
|
chart
|
||||||
|
@ -80,8 +75,8 @@ let make = (~complexPower: DistributionTypes.complexPower) => {
|
||||||
{x |> E.Float.toString |> ReasonReact.string}
|
{x |> E.Float.toString |> ReasonReact.string}
|
||||||
</th>
|
</th>
|
||||||
<th className="px-4 py-2 border ">
|
<th className="px-4 py-2 border ">
|
||||||
{complexPower
|
{distPlus
|
||||||
|> DistFunctor.ComplexPower.T.Integral.xToY(~cache=None, x)
|
|> DistFunctor.DistPlus.T.Integral.xToY(~cache=None, x)
|
||||||
|> E.Float.with2DigitsPrecision
|
|> E.Float.with2DigitsPrecision
|
||||||
|> ReasonReact.string}
|
|> ReasonReact.string}
|
||||||
</th>
|
</th>
|
|
@ -388,7 +388,7 @@ module Shape = {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module ComplexPower = {
|
module DistPlus = {
|
||||||
open DistributionTypes;
|
open DistributionTypes;
|
||||||
let make =
|
let make =
|
||||||
(
|
(
|
||||||
|
@ -398,7 +398,7 @@ module ComplexPower = {
|
||||||
~unit=UnspecifiedDistribution,
|
~unit=UnspecifiedDistribution,
|
||||||
(),
|
(),
|
||||||
)
|
)
|
||||||
: complexPower => {
|
: distPlus => {
|
||||||
let integral = Shape.T.Integral.get(~cache=None, shape);
|
let integral = Shape.T.Integral.get(~cache=None, shape);
|
||||||
{shape, domain, integralCache: integral, unit, guesstimatorString};
|
{shape, domain, integralCache: integral, unit, guesstimatorString};
|
||||||
};
|
};
|
||||||
|
@ -409,7 +409,7 @@ module ComplexPower = {
|
||||||
~domain=?,
|
~domain=?,
|
||||||
~unit=?,
|
~unit=?,
|
||||||
~guesstimatorString=?,
|
~guesstimatorString=?,
|
||||||
t: complexPower,
|
t: distPlus,
|
||||||
) => {
|
) => {
|
||||||
shape: E.O.default(t.shape, shape),
|
shape: E.O.default(t.shape, shape),
|
||||||
integralCache: E.O.default(t.integralCache, integralCache),
|
integralCache: E.O.default(t.integralCache, integralCache),
|
||||||
|
@ -420,8 +420,8 @@ module ComplexPower = {
|
||||||
|
|
||||||
module T =
|
module T =
|
||||||
Dist({
|
Dist({
|
||||||
type t = DistributionTypes.complexPower;
|
type t = DistributionTypes.distPlus;
|
||||||
type integral = DistributionTypes.complexPower;
|
type integral = DistributionTypes.distPlus;
|
||||||
let toShape = ({shape, _}: t) => shape;
|
let toShape = ({shape, _}: t) => shape;
|
||||||
let shapeFn = (fn, t: t) => t |> toShape |> fn;
|
let shapeFn = (fn, t: t) => t |> toShape |> fn;
|
||||||
let toContinuous = shapeFn(Shape.T.toContinuous);
|
let toContinuous = shapeFn(Shape.T.toContinuous);
|
||||||
|
|
29
src/core/DistPlusIngredients.re
Normal file
29
src/core/DistPlusIngredients.re
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
open DistributionTypes;
|
||||||
|
|
||||||
|
let make =
|
||||||
|
(~guesstimatorString, ~domain=Complete, ~unit=UnspecifiedDistribution, ())
|
||||||
|
: distPlusIngredients => {
|
||||||
|
guesstimatorString,
|
||||||
|
domain,
|
||||||
|
unit,
|
||||||
|
};
|
||||||
|
|
||||||
|
let toDistPlus = (~sampleCount, t: distPlusIngredients) => {
|
||||||
|
let shape =
|
||||||
|
Guesstimator.stringToMixedShape(
|
||||||
|
~string=t.guesstimatorString,
|
||||||
|
~sampleCount,
|
||||||
|
(),
|
||||||
|
)
|
||||||
|
|> E.O.bind(_, DistFunctor.Mixed.clean);
|
||||||
|
shape
|
||||||
|
|> E.O.fmap(shape =>
|
||||||
|
DistFunctor.DistPlus.make(
|
||||||
|
~shape,
|
||||||
|
~domain=t.domain,
|
||||||
|
~unit=t.unit,
|
||||||
|
~guesstimatorString=None,
|
||||||
|
(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
|
@ -52,13 +52,7 @@ type distributionUnit =
|
||||||
| UnspecifiedDistribution
|
| UnspecifiedDistribution
|
||||||
| TimeDistribution(TimeTypes.timeVector);
|
| TimeDistribution(TimeTypes.timeVector);
|
||||||
|
|
||||||
type genericDistribution = {
|
type distPlus = {
|
||||||
generationSource,
|
|
||||||
domain,
|
|
||||||
unit: distributionUnit,
|
|
||||||
};
|
|
||||||
|
|
||||||
type complexPower = {
|
|
||||||
shape,
|
shape,
|
||||||
domain,
|
domain,
|
||||||
integralCache: continuousShape,
|
integralCache: continuousShape,
|
||||||
|
@ -66,6 +60,12 @@ type complexPower = {
|
||||||
guesstimatorString: option(string),
|
guesstimatorString: option(string),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type distPlusIngredients = {
|
||||||
|
guesstimatorString: string,
|
||||||
|
domain,
|
||||||
|
unit: distributionUnit,
|
||||||
|
};
|
||||||
|
|
||||||
module DistributionUnit = {
|
module DistributionUnit = {
|
||||||
let toJson = (distributionUnit: distributionUnit) =>
|
let toJson = (distributionUnit: distributionUnit) =>
|
||||||
switch (distributionUnit) {
|
switch (distributionUnit) {
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
open DistributionTypes;
|
|
||||||
|
|
||||||
let make =
|
|
||||||
(~generationSource, ~domain=Complete, ~unit=UnspecifiedDistribution, ())
|
|
||||||
: genericDistribution => {
|
|
||||||
generationSource,
|
|
||||||
domain,
|
|
||||||
unit,
|
|
||||||
};
|
|
||||||
|
|
||||||
let toComplexPower = (~sampleCount, t: genericDistribution) => {
|
|
||||||
let shape =
|
|
||||||
switch (t.generationSource) {
|
|
||||||
| GuesstimatorString(s) =>
|
|
||||||
Guesstimator.stringToMixedShape(~string=s, ~sampleCount, ())
|
|
||||||
|> E.O.bind(_, DistFunctor.Mixed.clean)
|
|
||||||
| Shape(shape) => Some(shape)
|
|
||||||
};
|
|
||||||
shape
|
|
||||||
|> E.O.fmap(shape =>
|
|
||||||
DistFunctor.ComplexPower.make(
|
|
||||||
~shape,
|
|
||||||
~domain=t.domain,
|
|
||||||
~unit=t.unit,
|
|
||||||
~guesstimatorString=None,
|
|
||||||
(),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -17,12 +17,12 @@ let propValue = (t: Prop.Value.t) => {
|
||||||
switch (t) {
|
switch (t) {
|
||||||
| SelectSingle(r) => r |> ReasonReact.string
|
| SelectSingle(r) => r |> ReasonReact.string
|
||||||
| ConditionalArray(r) => "Array" |> ReasonReact.string
|
| ConditionalArray(r) => "Array" |> ReasonReact.string
|
||||||
| GenericDistribution(r) =>
|
| DistPlusIngredients(r) =>
|
||||||
let newDistribution =
|
let newDistribution =
|
||||||
GenericDistribution.toComplexPower(~sampleCount=1000, r);
|
DistPlusIngredients.toDistPlus(~sampleCount=1000, r);
|
||||||
switch (newDistribution) {
|
switch (newDistribution) {
|
||||||
| Some(distribution) =>
|
| Some(distribution) =>
|
||||||
<div> <ComplexPowerChart complexPower=distribution /> </div>
|
<div> <DistPlusChart distPlus=distribution /> </div>
|
||||||
| None => "Something went wrong" |> ReasonReact.string
|
| None => "Something went wrong" |> ReasonReact.string
|
||||||
};
|
};
|
||||||
| FloatCdf(_) => <div />
|
| FloatCdf(_) => <div />
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Value = {
|
||||||
| DateTime(MomentRe.Moment.t)
|
| DateTime(MomentRe.Moment.t)
|
||||||
| FloatPoint(float)
|
| FloatPoint(float)
|
||||||
| Probability(float)
|
| Probability(float)
|
||||||
| GenericDistribution(DistributionTypes.genericDistribution)
|
| DistPlusIngredients(DistributionTypes.distPlusIngredients)
|
||||||
| ConditionalArray(array(conditional))
|
| ConditionalArray(array(conditional))
|
||||||
| FloatCdf(string);
|
| FloatCdf(string);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ module ValueCluster = {
|
||||||
[ | `combination(range(MomentRe.Moment.t)) | `item(string)],
|
[ | `combination(range(MomentRe.Moment.t)) | `item(string)],
|
||||||
)
|
)
|
||||||
| Probability([ | `item(string)])
|
| Probability([ | `item(string)])
|
||||||
| GenericDistribution([ | `item(DistributionTypes.genericDistribution)])
|
| DistPlusIngredients([ | `item(DistributionTypes.distPlusIngredients)])
|
||||||
| ConditionalArray([ | `item(array(conditional))])
|
| ConditionalArray([ | `item(array(conditional))])
|
||||||
| FloatCdf([ | `item(string)]);
|
| FloatCdf([ | `item(string)]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -111,12 +111,10 @@ module Model = {
|
||||||
let getGlobalCatastropheChance = dateTime => {
|
let getGlobalCatastropheChance = dateTime => {
|
||||||
let model = GlobalCatastrophe.Model.make(dateTime);
|
let model = GlobalCatastrophe.Model.make(dateTime);
|
||||||
switch (model) {
|
switch (model) {
|
||||||
| Prop.Value.GenericDistribution(genericDistribution) =>
|
| Prop.Value.DistPlusIngredients(distPlusIngredients) =>
|
||||||
genericDistribution
|
distPlusIngredients
|
||||||
|> GenericDistribution.toComplexPower(~sampleCount=1000)
|
|> DistPlusIngredients.toDistPlus(~sampleCount=1000)
|
||||||
|> E.O.fmap(
|
|> E.O.fmap(DistFunctor.DistPlus.T.Integral.xToY(~cache=None, 18.0))
|
||||||
DistFunctor.ComplexPower.T.Integral.xToY(~cache=None, 18.0),
|
|
||||||
)
|
|
||||||
| _ => None
|
| _ => None
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -155,24 +153,22 @@ module Model = {
|
||||||
foo |> E.O.default("");
|
foo |> E.O.default("");
|
||||||
};
|
};
|
||||||
|
|
||||||
let genericDistribution =
|
let distPlusIngredients =
|
||||||
GenericDistribution.make(
|
DistPlusIngredients.make(
|
||||||
~generationSource=GuesstimatorString(str),
|
~guesstimatorString=str,
|
||||||
~domain=Complete,
|
~domain=Complete,
|
||||||
~unit=UnspecifiedDistribution,
|
~unit=UnspecifiedDistribution,
|
||||||
(),
|
(),
|
||||||
);
|
);
|
||||||
Prop.Value.GenericDistribution(genericDistribution);
|
Prop.Value.DistPlusIngredients(distPlusIngredients);
|
||||||
|
|
||||||
| CHANCE_OF_EXISTENCE =>
|
| CHANCE_OF_EXISTENCE =>
|
||||||
Prop.Value.GenericDistribution(
|
Prop.Value.DistPlusIngredients(
|
||||||
GenericDistribution.make(
|
DistPlusIngredients.make(
|
||||||
~generationSource=
|
~guesstimatorString=
|
||||||
GuesstimatorString(
|
GuesstimatorDist.min(
|
||||||
GuesstimatorDist.min(
|
GlobalCatastrophe.guesstimatorString,
|
||||||
GlobalCatastrophe.guesstimatorString,
|
GuesstimatorDist.logNormal(40., 4.),
|
||||||
GuesstimatorDist.logNormal(40., 4.),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
~domain=RightLimited({xPoint: 100., excludingProbabilityMass: 0.3}),
|
~domain=RightLimited({xPoint: 100., excludingProbabilityMass: 0.3}),
|
||||||
~unit=TimeDistribution({zero: currentDateTime, unit: `years}),
|
~unit=TimeDistribution({zero: currentDateTime, unit: `years}),
|
||||||
|
|
|
@ -2,13 +2,13 @@ let guesstimatorString = "20 to 80";
|
||||||
|
|
||||||
module Model = {
|
module Model = {
|
||||||
let make = (currentDateTime: MomentRe.Moment.t) => {
|
let make = (currentDateTime: MomentRe.Moment.t) => {
|
||||||
let genericDistribution =
|
let distPlusIngredients =
|
||||||
GenericDistribution.make(
|
DistPlusIngredients.make(
|
||||||
~generationSource=GuesstimatorString(guesstimatorString),
|
~guesstimatorString,
|
||||||
~unit=TimeDistribution({zero: currentDateTime, unit: `years}),
|
~unit=TimeDistribution({zero: currentDateTime, unit: `years}),
|
||||||
(),
|
(),
|
||||||
);
|
);
|
||||||
Prop.Value.GenericDistribution(genericDistribution);
|
Prop.Value.DistPlusIngredients(distPlusIngredients);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user