Simple getYIntegral works for mixed Distributions
This commit is contained in:
parent
4d1cc7094f
commit
918791fcd0
|
@ -9,7 +9,7 @@ let mixedDist =
|
||||||
GenericDistribution.make(
|
GenericDistribution.make(
|
||||||
~generationSource=
|
~generationSource=
|
||||||
GuesstimatorString(
|
GuesstimatorString(
|
||||||
"mm(floor(uniform(40, 50)), normal(50,10), [.5,.5])",
|
"mm(floor(uniform(20, 30)), normal(50,10), [.5,.5])",
|
||||||
),
|
),
|
||||||
~probabilityType=Pdf,
|
~probabilityType=Pdf,
|
||||||
~domain=Complete,
|
~domain=Complete,
|
||||||
|
|
|
@ -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]
|
[@react.component]
|
||||||
let make = (~dist) => {
|
let make = (~dist) => {
|
||||||
switch ((dist: option(DistributionTypes.genericDistribution))) {
|
switch ((dist: option(DistributionTypes.genericDistribution))) {
|
||||||
|
@ -74,13 +119,17 @@ let make = (~dist) => {
|
||||||
|> Shape.XYShape.scaleCdfTo
|
|> Shape.XYShape.scaleCdfTo
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Continuous
|
<Mixed
|
||||||
data={
|
data={
|
||||||
|
continuous:
|
||||||
n
|
n
|
||||||
|> Shape.XYShape.Range.integrateWithTriangles
|
|> Shape.Continuous.toCdf
|
||||||
|> E.O.toExt("")
|
|
||||||
|> Shape.XYShape.Range.derivative
|
|
||||||
|> E.O.toExt("")
|
|> E.O.toExt("")
|
||||||
|
|> Shape.XYShape.scaleCdfTo
|
||||||
|
|> Shape.Continuous.toPdf
|
||||||
|
|> E.O.toExt(""),
|
||||||
|
discrete: d,
|
||||||
|
discreteProbabilityMassFraction: f,
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Continuous
|
<Continuous
|
||||||
|
|
|
@ -191,7 +191,7 @@ module Mixed = {
|
||||||
};
|
};
|
||||||
|
|
||||||
let getYIntegral =
|
let getYIntegral =
|
||||||
(t: DistributionTypes.mixedShape, x: float): option(float) => {
|
(x: float, t: DistributionTypes.mixedShape): option(float) => {
|
||||||
let c = t.continuous |> Continuous.findIntegralY(x);
|
let c = t.continuous |> Continuous.findIntegralY(x);
|
||||||
let d = Discrete.findIntegralY(x, t.discrete);
|
let d = Discrete.findIntegralY(x, t.discrete);
|
||||||
switch (c, d) {
|
switch (c, d) {
|
||||||
|
@ -199,6 +199,10 @@ module Mixed = {
|
||||||
| _ => None
|
| _ => None
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
//Do the math to add these distributions together
|
||||||
|
// let integral =
|
||||||
|
// (x: float, t: DistributionTypes.mixedShape): option(XYShape.t) => {
|
||||||
|
// };
|
||||||
};
|
};
|
||||||
|
|
||||||
module Any = {
|
module Any = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user