Merge branch 'master' into improvements/1080
This commit is contained in:
commit
a81845bcc2
|
@ -5,13 +5,14 @@ let data: DistributionTypes.xyShape = {
|
||||||
|
|
||||||
let mixedDist =
|
let mixedDist =
|
||||||
GenericDistribution.make(
|
GenericDistribution.make(
|
||||||
~generationSource=GuesstimatorString("mm(3, normal(5,1), [.5,.5])"),
|
~generationSource=
|
||||||
|
GuesstimatorString("mm(uniform(10,12), normal(5,1), [.5,.5])"),
|
||||||
~probabilityType=Pdf,
|
~probabilityType=Pdf,
|
||||||
~domain=Complete,
|
~domain=Complete,
|
||||||
~unit=UnspecifiedDistribution,
|
~unit=UnspecifiedDistribution,
|
||||||
(),
|
(),
|
||||||
)
|
)
|
||||||
|> GenericDistribution.renderIfNeeded(~sampleCount=3000);
|
|> GenericDistribution.renderIfNeeded(~sampleCount=1000);
|
||||||
|
|
||||||
let timeDist =
|
let timeDist =
|
||||||
GenericDistribution.make(
|
GenericDistribution.make(
|
||||||
|
@ -30,7 +31,7 @@ let timeDist =
|
||||||
}),
|
}),
|
||||||
(),
|
(),
|
||||||
)
|
)
|
||||||
|> GenericDistribution.renderIfNeeded(~sampleCount=3000);
|
|> GenericDistribution.renderIfNeeded(~sampleCount=1000);
|
||||||
|
|
||||||
let domainLimitedDist =
|
let domainLimitedDist =
|
||||||
GenericDistribution.make(
|
GenericDistribution.make(
|
||||||
|
@ -40,7 +41,7 @@ let domainLimitedDist =
|
||||||
~unit=UnspecifiedDistribution,
|
~unit=UnspecifiedDistribution,
|
||||||
(),
|
(),
|
||||||
)
|
)
|
||||||
|> GenericDistribution.renderIfNeeded(~sampleCount=3000);
|
|> GenericDistribution.renderIfNeeded(~sampleCount=1000);
|
||||||
|
|
||||||
let distributions = () =>
|
let distributions = () =>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -32,4 +32,17 @@ let renderIfNeeded =
|
||||||
);
|
);
|
||||||
| Shape(_) => Some(t)
|
| Shape(_) => Some(t)
|
||||||
};
|
};
|
||||||
};
|
} /* }*/;
|
||||||
|
|
||||||
|
// let getTimeY =
|
||||||
|
// (t: genericDistribution, point: TimeTypes.RelativeTimePoint.timeInVector) => {
|
||||||
|
// switch (t) {
|
||||||
|
// | {
|
||||||
|
// generationSource: Shape(shape),
|
||||||
|
// probabilityType: Pdf,
|
||||||
|
// unit: Time(timeVector),
|
||||||
|
// } =>
|
||||||
|
// TimeTypes.RelativeTimePoint.toXValue(timeVector, point)
|
||||||
|
// |> E.O.fmap(x => Shape.Mixed.getY(t, x))
|
||||||
|
// | _ => 2.0
|
||||||
|
// };
|
|
@ -6,6 +6,10 @@ let _lastElement = (a: array('a)) =>
|
||||||
| n => Belt.Array.get(a, n - 1)
|
| n => Belt.Array.get(a, n - 1)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type pointInRange =
|
||||||
|
| Unbounded
|
||||||
|
| X(float);
|
||||||
|
|
||||||
module XYShape = {
|
module XYShape = {
|
||||||
type t = xyShape;
|
type t = xyShape;
|
||||||
|
|
||||||
|
@ -37,8 +41,19 @@ module XYShape = {
|
||||||
fromArrays(xs, ys);
|
fromArrays(xs, ys);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let getY = (t: t, x: float) => x;
|
||||||
|
|
||||||
let integral = transverse((aCurrent, aLast) => aCurrent +. aLast);
|
let integral = transverse((aCurrent, aLast) => aCurrent +. aLast);
|
||||||
let derivative = transverse((aCurrent, aLast) => aCurrent -. aLast);
|
let derivative = transverse((aCurrent, aLast) => aCurrent -. aLast);
|
||||||
|
|
||||||
|
let massWithin = (t: t, left: pointInRange, right: pointInRange) => {
|
||||||
|
switch (left, right) {
|
||||||
|
| (Unbounded, Unbounded) => t |> ySum
|
||||||
|
| (Unbounded, X(f)) => t |> integral |> getY(_, f)
|
||||||
|
| (X(f), Unbounded) => ySum(t) -. getY(integral(t), f)
|
||||||
|
| (X(l), X(r)) => getY(integral(t), r) -. getY(integral(t), l)
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
module Continuous = {
|
module Continuous = {
|
||||||
|
@ -99,6 +114,25 @@ module Mixed = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module Any = {
|
||||||
|
type t = DistributionTypes.pointsType;
|
||||||
|
|
||||||
|
let x = (t: t, x: float) =>
|
||||||
|
switch (t) {
|
||||||
|
| Mixed(m) => `mixed(Mixed.getY(m, x))
|
||||||
|
| Discrete(discreteShape) => `discrete(Discrete.findY(x, discreteShape))
|
||||||
|
| Continuous(continuousShape) =>
|
||||||
|
`continuous(Continuous.findY(x, continuousShape))
|
||||||
|
};
|
||||||
|
|
||||||
|
let massInRange = (t: t, left: pointInRange, right: pointInRange) =>
|
||||||
|
switch (t) {
|
||||||
|
| Mixed(m) => 3.0
|
||||||
|
| Discrete(discreteShape) => 2.0
|
||||||
|
| Continuous(continuousShape) => 3.0
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
module DomainMixed = {
|
module DomainMixed = {
|
||||||
type t = {
|
type t = {
|
||||||
mixedShape,
|
mixedShape,
|
||||||
|
|
|
@ -126,12 +126,14 @@ module Model = {
|
||||||
currentDateTime,
|
currentDateTime,
|
||||||
yearlyMeanGrowthRateIfNotClosed(group),
|
yearlyMeanGrowthRateIfNotClosed(group),
|
||||||
);
|
);
|
||||||
|
|
||||||
let str =
|
let str =
|
||||||
switch (xRisk) {
|
switch (xRisk) {
|
||||||
| Some({truthValue: true}) => "0"
|
| Some({truthValue: true}) => "0"
|
||||||
| Some({truthValue: false}) => difference
|
| Some({truthValue: false}) => difference
|
||||||
| None => "uniform(0,1) > .3 ? " ++ difference ++ ": 0"
|
| None => "uniform(0,1) > .3 ? " ++ difference ++ ": 0"
|
||||||
};
|
};
|
||||||
|
|
||||||
let genericDistribution =
|
let genericDistribution =
|
||||||
GenericDistribution.make(
|
GenericDistribution.make(
|
||||||
~generationSource=GuesstimatorString(str),
|
~generationSource=GuesstimatorString(str),
|
||||||
|
|
|
@ -48,8 +48,8 @@ const toPdf = (values, sampleCount, min, max) => {
|
||||||
const ratioSize$ = ratioSize(samples);
|
const ratioSize$ = ratioSize(samples);
|
||||||
const width = ratioSize$ === 'SMALL' ? 20 : 1;
|
const width = ratioSize$ === 'SMALL' ? 20 : 1;
|
||||||
|
|
||||||
const cdf = samples.toCdf({ size: sampleCount, width, min, max });
|
const pdf = samples.toPdf({ size: sampleCount, width, min, max });
|
||||||
continuous = cdf;
|
continuous = pdf;
|
||||||
}
|
}
|
||||||
return {continuous, discrete};
|
return {continuous, discrete};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user