Simple getYIntegral works for mixed Distributions

This commit is contained in:
Ozzie Gooen 2020-02-18 19:18:07 +00:00
parent 4d1cc7094f
commit 918791fcd0
3 changed files with 61 additions and 8 deletions

View File

@ -9,7 +9,7 @@ let mixedDist =
GenericDistribution.make(
~generationSource=
GuesstimatorString(
"mm(floor(uniform(40, 50)), normal(50,10), [.5,.5])",
"mm(floor(uniform(20, 30)), normal(50,10), [.5,.5])",
),
~probabilityType=Pdf,
~domain=Complete,

View File

@ -51,6 +51,51 @@ module Continuous = {
};
};
module Mixed = {
[@react.component]
let make = (~data: DistributionTypes.mixedShape) => {
let (x, setX) = React.useState(() => 0.);
let chart =
React.useMemo1(
() =>
<CdfChart__Plain
data={data.continuous}
color={`hex("333")}
onHover={r => setX(_ => r)}
/>,
[|data|],
);
<div>
chart
<table className="table-auto">
<thead>
<tr>
<th className="px-4 py-2"> {"X Point" |> ReasonReact.string} </th>
<th className="px-4 py-2"> {"Y Pount" |> ReasonReact.string} </th>
<th className="px-4 py-2">
{"Y Integral to Point" |> ReasonReact.string}
</th>
</tr>
</thead>
<tbody>
<tr>
<th className="px-4 py-2 border ">
{x |> E.Float.toString |> ReasonReact.string}
</th>
<th className="px-4 py-2 border ">
{Shape.Mixed.getYIntegral(x, data)
|> E.O.fmap(E.Float.with2DigitsPrecision)
|> E.O.default("")
|> ReasonReact.string}
</th>
</tr>
</tbody>
</table>
<div />
</div>;
};
};
[@react.component]
let make = (~dist) => {
switch ((dist: option(DistributionTypes.genericDistribution))) {
@ -74,13 +119,17 @@ let make = (~dist) => {
|> Shape.XYShape.scaleCdfTo
}
/>
<Continuous
<Mixed
data={
continuous:
n
|> Shape.XYShape.Range.integrateWithTriangles
|> E.O.toExt("")
|> Shape.XYShape.Range.derivative
|> Shape.Continuous.toCdf
|> E.O.toExt("")
|> Shape.XYShape.scaleCdfTo
|> Shape.Continuous.toPdf
|> E.O.toExt(""),
discrete: d,
discreteProbabilityMassFraction: f,
}
/>
<Continuous

View File

@ -191,7 +191,7 @@ module Mixed = {
};
let getYIntegral =
(t: DistributionTypes.mixedShape, x: float): option(float) => {
(x: float, t: DistributionTypes.mixedShape): option(float) => {
let c = t.continuous |> Continuous.findIntegralY(x);
let d = Discrete.findIntegralY(x, t.discrete);
switch (c, d) {
@ -199,6 +199,10 @@ module Mixed = {
| _ => None
};
};
//Do the math to add these distributions together
// let integral =
// (x: float, t: DistributionTypes.mixedShape): option(XYShape.t) => {
// };
};
module Any = {