LimitedDomainCdf file
This commit is contained in:
parent
088a623bef
commit
089dfeeef2
33
src/LimitedDomainCdf.re
Normal file
33
src/LimitedDomainCdf.re
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
type t = {
|
||||||
|
distribution: Types.distribution,
|
||||||
|
domainMaxX: float,
|
||||||
|
};
|
||||||
|
|
||||||
|
let fromCdf = (cdf: Types.cdf, domainMaxX: float, probabilityAtMaxX: float) => {
|
||||||
|
let distribution: Types.distribution = {
|
||||||
|
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 chanceByX = (t: t) => t.distribution;
|
||||||
|
|
||||||
|
let domainMaxX = (t: t) => t.domainMaxX;
|
||||||
|
|
||||||
|
let probabilityDistribution = (t: t) =>
|
||||||
|
t.distribution |> CdfLibrary.Distribution.toPdf;
|
||||||
|
|
||||||
|
let probability = (t: t, xPoint: float) =>
|
||||||
|
CdfLibrary.Distribution.findY(xPoint, probabilityDistribution(t));
|
||||||
|
|
||||||
|
let cumulativeProbability = (t: t, xPoint: float) =>
|
||||||
|
CdfLibrary.Distribution.findY(xPoint, t.distribution);
|
|
@ -38,7 +38,7 @@ module Value = {
|
||||||
| SelectSingle(r) => r |> ReasonReact.string
|
| SelectSingle(r) => r |> ReasonReact.string
|
||||||
| FloatCdf(r) =>
|
| FloatCdf(r) =>
|
||||||
let cdf: Types.distribution =
|
let cdf: Types.distribution =
|
||||||
CdfLibrary.Distribution.fromString(r, 1000);
|
CdfLibrary.Distribution.fromString(r, 2000);
|
||||||
<>
|
<>
|
||||||
<ForetoldComponents.CdfChart__Large
|
<ForetoldComponents.CdfChart__Large
|
||||||
cdf={Types.toComponentsDist(cdf)}
|
cdf={Types.toComponentsDist(cdf)}
|
||||||
|
|
|
@ -6,4 +6,12 @@ type distribution = {
|
||||||
let toComponentsDist = (d: distribution): ForetoldComponents.Types.Dist.t => {
|
let toComponentsDist = (d: distribution): ForetoldComponents.Types.Dist.t => {
|
||||||
xs: d.xs,
|
xs: d.xs,
|
||||||
ys: d.ys,
|
ys: d.ys,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type pdf = distribution;
|
||||||
|
type cdf = distribution;
|
||||||
|
|
||||||
|
let foo = (b: pdf) => 3.9;
|
||||||
|
let bar: cdf = {xs: [||], ys: [||]};
|
||||||
|
|
||||||
|
let cc = foo(bar);
|
Loading…
Reference in New Issue
Block a user