Removes obsolete code

This commit is contained in:
Roman Galochkin 2020-02-18 11:51:11 +03:00
parent 62d5114dfe
commit 08a2f9b058
8 changed files with 12 additions and 238 deletions

View File

@ -1,33 +0,0 @@
// type t = {
// distribution: Types.ContinuousDistribution.t,
// domainMaxX: float,
// };
// let make = (~distribution, ~domainMaxX): t => {distribution, domainMaxX};
// let fromCdf =
// (
// cdf: Types.ContinuousDistribution.t,
// domainMaxX: float,
// probabilityAtMaxX: float,
// ) => {
// let distribution: Types.ContinuousDistribution.t = {
// xs: cdf.xs,
// ys: cdf.ys |> E.A.fmap(r => r *. probabilityAtMaxX),
// };
// {distribution, domainMaxX};
// };
// let _lastElement = (a: array('a)) =>
// switch (Belt.Array.size(a)) {
// | 0 => None
// | n => Belt.Array.get(a, n)
// };
// let probabilityBeforeDomainMax = (t: t) => _lastElement(t.distribution.ys);
// let domainMaxX = (t: t) => t.domainMaxX /* CdfLibrary.Distribution.findX(yPoint, t.distribution)*/;
// let probabilityDistribution = (t: t) =>
// t.distribution |> CdfLibrary.Distribution.toPdf;
// let probability = (t: t, xPoint: float) =>
// CdfLibrary.Distribution.findY(xPoint, probabilityDistribution(t));
// let probabilityInverse = (t: t, yPoint: float) =>
// CdfLibrary.Distribution.findX(yPoint, probabilityDistribution(t));
// let cumulativeProbability = (t: t, xPoint: float) =>
// CdfLibrary.Distribution.findY(xPoint, t.distribution);
/* let cumulativeProbabilityInverse = (t: t, yPoint: float) =*/

View File

@ -1,50 +0,0 @@
// open EAFunds_Data;
// let handleChange = (handleChange, event) =>
// handleChange(ReactEvent.Form.target(event)##value);
// [@react.component]
// let make = () => {
// let (year, setYear) = React.useState(() => 2021.);
// <>
// <h1> {"EA Funds Forecasting Model 0.1" |> ReasonReact.string} </h1>
// <input
// type_="number"
// value={year |> Js.Float.toString}
// onChange={handleChange(r =>
// switch (Js.Float.fromString(r)) {
// | r when r >= 2020.0 && r <= 2050.0 => setYear(_ => r)
// | _ => ()
// }
// )}
// />
// <table className="table-auto">
// <thead>
// <tr>
// <th className="px-4 py-2"> {"Fund Name" |> ReasonReact.string} </th>
// <th className="px-4 py-2"> {"Donations" |> ReasonReact.string} </th>
// <th className="px-4 py-2"> {"Payouts" |> ReasonReact.string} </th>
// </tr>
// </thead>
// <tbody>
// {funds
// |> Belt.Array.map(_, r =>
// <tr>
// <th className="px-4 py-2 border ">
// {r.name |> ReasonReact.string}
// </th>
// <th className="px-4 py-2 border font-normal">
// {EAFunds_Model.go(r.group, year, DONATIONS)
// |> Model.InputTypes.to_string
// |> ReasonReact.string}
// </th>
// <th className="px-4 py-2 border font-normal">
// {EAFunds_Model.go(r.group, year, PAYOUTS)
// |> Model.InputTypes.to_string
// |> ReasonReact.string}
// </th>
// </tr>
// )
// |> ReasonReact.array}
// </tbody>
// </table>
// </>;
/* }*/

View File

@ -1,56 +0,0 @@
type senate =
| DEMOCRAT_VICTORY;
type house =
| DEMOCRAT_VICTORY;
type statement =
| Senate(senate)
| House(house);
type outcome =
| Bool(bool)
| Option(string);
type fullStatement = {
statement,
outcome,
};
type jointStatement = {
statements: array(fullStatement),
probability: option(float),
};
let foo = (joint: jointStatement) => {
[|
{
statements: [|
{statement: Senate(DEMOCRAT_VICTORY), outcome: Bool(true)},
{statement: House(DEMOCRAT_VICTORY), outcome: Bool(true)},
|],
probability: Some(0.2),
},
{
statements: [|
{statement: Senate(DEMOCRAT_VICTORY), outcome: Bool(true)},
{statement: House(DEMOCRAT_VICTORY), outcome: Bool(false)},
|],
probability: Some(0.2),
},
{
statements: [|
{statement: Senate(DEMOCRAT_VICTORY), outcome: Bool(false)},
{statement: House(DEMOCRAT_VICTORY), outcome: Bool(true)},
|],
probability: Some(0.5),
},
{
statements: [|
{statement: Senate(DEMOCRAT_VICTORY), outcome: Bool(false)},
{statement: House(DEMOCRAT_VICTORY), outcome: Bool(false)},
|],
probability: Some(0.1),
},
|];
};

View File

@ -1,60 +0,0 @@
module Math = {
let normal = (mean: float, std: float) =>
Js.Float.(
{
let nMean = toString(mean);
let nStd = toString(std);
{j|normal($(nMean), $(nStd))|j};
}
);
let divide = (str1: string, str2: string) => {j|$(str1)/$(str2)|j};
};
type param =
| SHARE_PRICE
| SHARES_OUTSTANDING
| MARKET_CAP;
type company = {
name: string,
currentPrice: option(float),
marketCap: option(float),
};
type otherSettings = {currentYear: int};
let sharesOutstanding = (price, marketCap) =>
switch (price, marketCap) {
| (Some(price), Some(marketCap)) =>
Some(GuesstimatorDist.divide(marketCap, price))
| _ => None
};
let rec run =
(
company: company,
year: int,
param: param,
otherSettings: otherSettings,
) => {
switch (param, year, company.currentPrice, company.marketCap) {
| (SHARE_PRICE, year, Some(price), _) when year > 2019 && year < 2030 =>
let diffYears = year - otherSettings.currentYear;
let diffPerYear = 0.1;
Some(
GuesstimatorDist.normal(price, float_of_int(diffYears) *. diffPerYear),
);
| (MARKET_CAP, year, _, Some(price)) when year > 2019 && year < 2030 =>
let diffYears = year - otherSettings.currentYear;
let diffPerYear = 0.1;
Some(
GuesstimatorDist.normal(price, float_of_int(diffYears) *. diffPerYear),
);
| (SHARES_OUTSTANDING, year, _, _) when year > 2019 && year < 2030 =>
let price = run(company, year, SHARE_PRICE, otherSettings);
let marketCap = run(company, year, MARKET_CAP, otherSettings);
sharesOutstanding(price, marketCap);
| _ => None
};
};

View File

@ -1,38 +0,0 @@
// open TimeTypes;
// type t = {
// timeVector,
// limitedDomainCdf: LimitedDomainCdf.t,
// };
// let make =
// (
// ~timeVector: timeVector,
// ~distribution: Types.ContinuousDistribution.t,
// ~probabilityAtMaxX: float,
// ~maxX: [ | `time(MomentRe.Moment.t) | `x(float)],
// )
// : t => {
// let domainMaxX =
// switch (maxX) {
// | `time(m) => TimePoint.fromMoment(timeVector, m)
// | `x(r) => r
// };
// let limitedDomainCdf =
// LimitedDomainCdf.fromCdf(distribution, domainMaxX, probabilityAtMaxX);
// {timeVector, limitedDomainCdf};
// };
// let probabilityBeforeDomainMax = (t: t) =>
// LimitedDomainCdf.probabilityBeforeDomainMax(t.limitedDomainCdf);
// let domainMaxX = (t: t) =>
// LimitedDomainCdf.probabilityBeforeDomainMax(t.limitedDomainCdf) /* |> (r => RelativeTimePoint.toTime(t.timeVector, XValue(r)))*/;
// let probability = (t: t, m: MomentRe.Moment.t) => {
// RelativeTimePoint.toXValue(t.timeVector, Time(m))
// |> LimitedDomainCdf.probability(t.limitedDomainCdf);
// };
// let probabilityInverse = (t: t, y: float) =>
// LimitedDomainCdf.probabilityInverse(t.limitedDomainCdf, y)
// |> (r => RelativeTimePoint.toTime(t.timeVector, XValue(r)));
// let cumulativeProbability = (t: t, m: MomentRe.Moment.t) =>
// RelativeTimePoint.toXValue(t.timeVector, Time(m))
// |> LimitedDomainCdf.cumulativeProbability(t.limitedDomainCdf);
// let cumulativeProbabilityInverse = (t: t, y: float) =>
/* LimitedDomainCdf.cumulativeProbabilityInverse(t.limitedDomainCdf, y*/

View File

@ -60,10 +60,14 @@ let make = (~dist) => {
}), }),
), ),
}) => }) =>
Js.log2("n", n);
Js.log2("d", d);
Js.log2("f", f);
Js.log2("dist", dist);
<div> <div>
<Continuous data={n |> Shape.Continuous.toPdf} /> <Continuous data={n |> Shape.Continuous.toPdf} />
{d |> Shape.Discrete.scaleYToTotal(f) |> Shape.Discrete.render} {d |> Shape.Discrete.scaleYToTotal(f) |> Shape.Discrete.render}
</div> </div>;
| _ => <div /> | _ => <div />
}; };
}; };

View File

@ -1,4 +1,5 @@
open DistributionTypes; open DistributionTypes;
let make = let make =
( (
~generationSource, ~generationSource,

View File

@ -1,11 +1,13 @@
type assumption = type assumption =
| ADDS_TO_1 | ADDS_TO_1
| ADDS_TO_CORRECT_PROBABILITY; | ADDS_TO_CORRECT_PROBABILITY;
type assumptions = { type assumptions = {
continuous: assumption, continuous: assumption,
discrete: assumption, discrete: assumption,
discreteProbabilityMass: option(float), discreteProbabilityMass: option(float),
}; };
let build = (~continuous, ~discrete, ~assumptions) => let build = (~continuous, ~discrete, ~assumptions) =>
switch (assumptions) { switch (assumptions) {
| { | {
@ -21,6 +23,7 @@ let build = (~continuous, ~discrete, ~assumptions) =>
~discreteProbabilityMassFraction=r, ~discreteProbabilityMassFraction=r,
), ),
) )
| { | {
continuous: ADDS_TO_1, continuous: ADDS_TO_1,
discrete: ADDS_TO_1, discrete: ADDS_TO_1,
@ -33,18 +36,21 @@ let build = (~continuous, ~discrete, ~assumptions) =>
~discreteProbabilityMassFraction=r, ~discreteProbabilityMassFraction=r,
), ),
) )
| { | {
continuous: ADDS_TO_1, continuous: ADDS_TO_1,
discrete: ADDS_TO_1, discrete: ADDS_TO_1,
discreteProbabilityMass: None, discreteProbabilityMass: None,
} => } =>
None None
| { | {
continuous: ADDS_TO_CORRECT_PROBABILITY, continuous: ADDS_TO_CORRECT_PROBABILITY,
discrete: ADDS_TO_1, discrete: ADDS_TO_1,
discreteProbabilityMass: None, discreteProbabilityMass: None,
} => } =>
None None
| { | {
continuous: ADDS_TO_1, continuous: ADDS_TO_1,
discrete: ADDS_TO_CORRECT_PROBABILITY, discrete: ADDS_TO_CORRECT_PROBABILITY,