From 088a623bef7e2355d4bbfd5da8d8d2fdafdbb3eb Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Thu, 13 Feb 2020 12:40:04 +0000 Subject: [PATCH] Use lognormal instead of normal --- src/lib/FloatCdf.re | 10 ++++++++++ src/lib/Prop.re | 7 ++----- src/models/EAFunds.re | 5 ++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/lib/FloatCdf.re b/src/lib/FloatCdf.re index d94c209b..f13e112b 100644 --- a/src/lib/FloatCdf.re +++ b/src/lib/FloatCdf.re @@ -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}; \ No newline at end of file diff --git a/src/lib/Prop.re b/src/lib/Prop.re index ddcae4ff..57a77e54 100644 --- a/src/lib/Prop.re +++ b/src/lib/Prop.re @@ -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); <> {