Use lognormal instead of normal

This commit is contained in:
Ozzie Gooen 2020-02-13 12:40:04 +00:00
parent b8d0368313
commit 088a623bef
3 changed files with 16 additions and 6 deletions

View File

@ -7,4 +7,14 @@ 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(std, ~digits=2);
{j|lognormal($(nMean), $(nStd))|j};
}
);
};
let divide = (str1: string, str2: string) => {j|$(str1)/$(str2)|j};

View File

@ -18,10 +18,7 @@ module Value = {
| Unselected => ""
}
| SelectSingle(r) => r
| FloatCdf(r) =>
let foo: Types.distribution =
CdfLibrary.Distribution.fromString(r, 100);
r;
| FloatCdf(r) => r
| Probability(r) => (r *. 100. |> Js.Float.toFixed) ++ "%"
| DateTime(r) => r |> MomentRe.Moment.defaultFormat
| FloatPoint(r) => r |> Js.Float.toFixed
@ -41,7 +38,7 @@ module Value = {
| SelectSingle(r) => r |> ReasonReact.string
| FloatCdf(r) =>
let cdf: Types.distribution =
CdfLibrary.Distribution.fromString(r, 100);
CdfLibrary.Distribution.fromString(r, 1000);
<>
<ForetoldComponents.CdfChart__Large
cdf={Types.toComponentsDist(cdf)}

View File

@ -78,7 +78,10 @@ module Model = {
let yearDiff = MomentRe.diff(dateTime, currentDateTime, `days) /. 365.;
let meanDiff = Js.Math.pow_float(~base=y.meanDiff, ~exp=yearDiff);
let stdDevDiff = Js.Math.pow_float(~base=y.meanDiff, ~exp=yearDiff);
FloatCdf.normal(currentValue *. meanDiff, firstYearStdDev *. stdDevDiff);
FloatCdf.logNormal(
currentValue *. meanDiff,
firstYearStdDev *. stdDevDiff,
);
};
let rec currentValue = (group: group, output) => {