Minor cleanup
This commit is contained in:
parent
1a547748c7
commit
17e40a9098
15
src/core/MixedCdf.re
Normal file
15
src/core/MixedCdf.re
Normal file
|
@ -0,0 +1,15 @@
|
|||
type t = DistributionTypes.mixedShape;
|
||||
|
||||
type yPdfPoint = {
|
||||
continuous: float,
|
||||
discrete: float,
|
||||
};
|
||||
|
||||
let getY = (t: t, x: float): yPdfPoint => {
|
||||
continuous: Shape.Continuous.findY(x, t.continuous),
|
||||
discrete: Shape.Discrete.findY(x, t.discrete),
|
||||
} /* }*/;
|
||||
|
||||
// let getIntegralY = (t: t, x: float): float => {
|
||||
// continuous: Shape.Continuous.findY(x, t.continuous),
|
||||
// discrete: Shape.Discrete.findY(x, t.discrete),
|
|
@ -14,9 +14,11 @@ module XYShape = {
|
|||
};
|
||||
|
||||
let fmap = (t: t, y): t => {xs: t.xs, ys: t.ys |> E.A.fmap(y)};
|
||||
|
||||
let yFold = (fn, t: t) => {
|
||||
E.A.fold_left(fn, 0., t.ys);
|
||||
};
|
||||
|
||||
let ySum = yFold((a, b) => a +. b);
|
||||
|
||||
let fromArrays = (xs, ys): t => {xs, ys};
|
||||
|
@ -34,8 +36,8 @@ module XYShape = {
|
|||
fromArrays(xs, ys);
|
||||
};
|
||||
|
||||
let derivative = transverse((aCurrent, aLast) => aCurrent -. aLast);
|
||||
let integral = transverse((aCurrent, aLast) => aCurrent +. aLast);
|
||||
let derivative = transverse((aCurrent, aLast) => aCurrent -. aLast);
|
||||
};
|
||||
|
||||
module Continuous = {
|
||||
|
@ -84,6 +86,16 @@ module Mixed = {
|
|||
discrete,
|
||||
discreteProbabilityMassFraction,
|
||||
};
|
||||
|
||||
type yPdfPoint = {
|
||||
continuous: float,
|
||||
discrete: float,
|
||||
};
|
||||
|
||||
let getY = (t: DistributionTypes.mixedShape, x: float): yPdfPoint => {
|
||||
continuous: Continuous.findY(x, t.continuous),
|
||||
discrete: Discrete.findY(x, t.discrete),
|
||||
};
|
||||
};
|
||||
|
||||
module DomainMixed = {
|
||||
|
|
|
@ -12,6 +12,11 @@ module Value = {
|
|||
| GenericDistribution(DistributionTypes.genericDistribution)
|
||||
| ConditionalArray(array(conditional))
|
||||
| FloatCdf(string);
|
||||
|
||||
module ConditionalArray = {
|
||||
let get = (conditionals: array(conditional), name: string) =>
|
||||
Belt.Array.getBy(conditionals, (c: conditional) => c.name == name);
|
||||
};
|
||||
};
|
||||
|
||||
module ValueCombination = {
|
||||
|
|
|
@ -17,4 +17,5 @@ let logNormal = (mean: float, std: float) => {
|
|||
);
|
||||
};
|
||||
|
||||
let divide = (str1: string, str2: string) => {j|$(str1)/$(str2)|j};
|
||||
let divide = (str1: string, str2: string) => {j|$(str1)/$(str2)|j};
|
||||
let min = (str1: string, str2: string) => {j|min($(str1),$(str2))|j};
|
|
@ -103,13 +103,19 @@ module Model = {
|
|||
| (_, CHANCE_OF_EXISTENCE) => 0.0
|
||||
};
|
||||
};
|
||||
|
||||
let xRisk = conditionals =>
|
||||
Prop.Value.ConditionalArray.get(conditionals, "Global Existential Event");
|
||||
|
||||
let make =
|
||||
(
|
||||
group: group,
|
||||
dateTime: MomentRe.Moment.t,
|
||||
currentDateTime: MomentRe.Moment.t,
|
||||
output: output,
|
||||
conditionals: array(Prop.Value.conditional),
|
||||
) => {
|
||||
let xRisk = xRisk(conditionals);
|
||||
switch (output) {
|
||||
| DONATIONS
|
||||
| PAYOUTS =>
|
||||
|
@ -120,16 +126,37 @@ module Model = {
|
|||
currentDateTime,
|
||||
yearlyMeanGrowthRateIfNotClosed(group),
|
||||
);
|
||||
let str =
|
||||
switch (xRisk) {
|
||||
| Some({truthValue: true}) => "0"
|
||||
| Some({truthValue: false}) => difference
|
||||
| None => "uniform(0,1) > .3 ? " ++ difference ++ ": 0"
|
||||
};
|
||||
let genericDistribution =
|
||||
GenericDistribution.make(
|
||||
~generationSource=GuesstimatorString(difference),
|
||||
~generationSource=GuesstimatorString(str),
|
||||
~probabilityType=Cdf,
|
||||
~domain=Complete,
|
||||
~unit=Unspecified,
|
||||
(),
|
||||
);
|
||||
Prop.Value.GenericDistribution(genericDistribution);
|
||||
| CHANCE_OF_EXISTENCE => Prop.Value.Probability(0.3)
|
||||
| CHANCE_OF_EXISTENCE =>
|
||||
Prop.Value.GenericDistribution(
|
||||
GenericDistribution.make(
|
||||
~generationSource=
|
||||
GuesstimatorString(
|
||||
GuesstimatorDist.min(
|
||||
GlobalCatastrophe.guesstimatorString,
|
||||
GuesstimatorDist.logNormal(40., 4.),
|
||||
),
|
||||
),
|
||||
~probabilityType=Cdf,
|
||||
~domain=RightLimited({xPoint: 100., excludingProbabilityMass: 0.3}),
|
||||
~unit=Time({zero: currentDateTime, unit: `years}),
|
||||
(),
|
||||
),
|
||||
)
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -158,7 +185,7 @@ module Interface = {
|
|||
Some(DateTime(intendedYear)),
|
||||
Some(DateTime(currentYear)),
|
||||
Some(SelectSingle(output)),
|
||||
_,
|
||||
Some(ConditionalArray(conditionals)),
|
||||
|] =>
|
||||
choiceFromString(fund)
|
||||
|> E.O.fmap(fund =>
|
||||
|
@ -167,6 +194,7 @@ module Interface = {
|
|||
intendedYear,
|
||||
currentYear,
|
||||
outputFromString(output),
|
||||
conditionals,
|
||||
)
|
||||
)
|
||||
| _ => None
|
||||
|
@ -229,9 +257,9 @@ module Interface = {
|
|||
SelectSingle({
|
||||
default: Some("Output"),
|
||||
options: [
|
||||
{name: "Donations | Exists", id: "donations"},
|
||||
{name: "Funding | Exists", id: "funding"},
|
||||
{name: "Exists", id: "exists"},
|
||||
{name: "Donations", id: "donations"},
|
||||
{name: "Funding", id: "funding"},
|
||||
{name: "Closing", id: "exists"},
|
||||
],
|
||||
}),
|
||||
(),
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
let guesstimatorString = GuesstimatorDist.logNormal(20., 3.);
|
||||
|
||||
module Model = {
|
||||
let make = (currentDateTime: MomentRe.Moment.t) => {
|
||||
let genericDistribution =
|
||||
GenericDistribution.make(
|
||||
~generationSource=
|
||||
GuesstimatorString(GuesstimatorDist.logNormal(20., 3.)),
|
||||
~generationSource=GuesstimatorString(guesstimatorString),
|
||||
~probabilityType=Cdf,
|
||||
~domain=RightLimited({xPoint: 200., excludingProbabilityMass: 0.3}),
|
||||
~unit=Time({zero: currentDateTime, unit: `years}),
|
||||
|
|
Loading…
Reference in New Issue
Block a user