Fixed issues with primary models

This commit is contained in:
Ozzie Gooen 2020-04-01 19:49:59 +01:00
parent e80bd4108e
commit 0ef6d106ea
3 changed files with 47 additions and 32 deletions

View File

@ -24,19 +24,32 @@ let toDistPlus =
t: distPlusIngredients,
)
: option(distPlus) => {
let samples =
Guesstimator.stringToSamples(t.guesstimatorString, sampleCount);
let shape = Samples.T.toShape(~samples, ~outputXYPoints, ~kernelWidth, ());
shape
|> E.O.fmap(
Distributions.DistPlus.make(
~shape=_,
~domain=t.domain,
~unit=t.unit,
~guesstimatorString=Some(t.guesstimatorString),
(),
),
)
|> E.O.fmap(Distributions.DistPlus.T.scaleToIntegralSum(~intendedSum=1.0))
|> applyTruncation(truncateTo);
let toDist = shape =>
Distributions.DistPlus.make(
~shape,
~domain=t.domain,
~unit=t.unit,
~guesstimatorString=Some(t.guesstimatorString),
(),
)
|> Distributions.DistPlus.T.scaleToIntegralSum(~intendedSum=1.0);
let parsed1 = MathJsParser.fromString(t.guesstimatorString);
let shape =
switch (parsed1) {
| Ok(r) =>
let shape = SymbolicDist.toShape(truncateTo |> E.O.default(10000), r);
Some(shape |> toDist);
| _ =>
let fewSamples = Guesstimator.stringToSamples(t.guesstimatorString, 10);
if (fewSamples |> E.A.length > 0) {
let samples =
Guesstimator.stringToSamples(t.guesstimatorString, sampleCount);
let shape =
Samples.T.toShape(~samples, ~outputXYPoints, ~kernelWidth, ());
shape |> E.O.fmap(toDist) |> applyTruncation(truncateTo);
} else {
None;
};
};
shape;
};

View File

@ -35,26 +35,26 @@ module Data = {
makeFundWithInfo(
"Animal Welfare Fund",
Fund(ANIMAL_WELFARE),
Some(4000.0),
Some(10.0),
Some(400000.0),
Some(100000.0),
),
makeFundWithInfo(
"Global Health Fund",
Fund(GLOBAL_HEALTH),
Some(4000.0),
Some(10.0),
Some(400000.0),
Some(100000.0),
),
makeFundWithInfo(
"Long Term Future Fund",
Fund(LONG_TERM_FUTURE),
Some(4000.0),
Some(10.0),
Some(400000.0),
Some(100000.0),
),
makeFundWithInfo(
"Meta Fund",
Fund(ANIMAL_WELFARE),
Some(4000.0),
Some(10.0),
Some(400000.0),
Some(100000.0),
),
makeFundWithInfo("All", All, None, None),
|];
@ -63,14 +63,14 @@ module Data = {
module Model = {
open Data;
let currentYear = 2020.;
let firstYearStdDev = 0.2;
let firstYearStdDev = 400000.;
type yearlyNumericDiff = {
meanDiff: float,
stdDiff: float,
};
let yearlyMeanGrowthRateIfNotClosed = (group: group): yearlyNumericDiff => {
{meanDiff: 1.1, stdDiff: 1.08};
{meanDiff: 1.1, stdDiff: 1.2};
};
let calculateDifference =
@ -141,10 +141,12 @@ module Model = {
| None =>
let foo =
getGlobalCatastropheChance(dateTime)
|> E.O.fmap(E.Float.with2DigitsPrecision)
|> E.O.fmap((r: string) =>
"uniform(0,1) > " ++ r ++ " ? " ++ difference ++ ": 0"
);
|> E.O.fmap(r => {
let chance = r;
let opposite = 1.0 -. r;
let reg = difference;
{j|mm(0, $reg, [$chance, $opposite])|j};
});
foo |> E.O.default("");
};

View File

@ -10,9 +10,9 @@ let normal = (mean: float, std: float) =>
let logNormal = (mean: float, std: float) => {
Js.Float.(
{
let nMean = toPrecisionWithPrecision(Js.Math.log10(mean), ~digits=4);
let nStd = toPrecisionWithPrecision(Js.Math.log10(std), ~digits=2);
{j|lognormal($(nMean), $(nStd))|j};
let nMean = toPrecisionWithPrecision(mean, ~digits=4);
let nStd = toPrecisionWithPrecision(std, ~digits=2);
{j|lognormal({mean: $(nMean), stdev: $(nStd)})|j};
}
);
};