Minor cleanup

This commit is contained in:
Ozzie Gooen 2020-02-19 17:49:42 +00:00
parent e5fb663c5d
commit 510519b24a
3 changed files with 5 additions and 27 deletions

View File

@ -31,7 +31,7 @@ module Mixed = {
{x |> E.Float.toString |> ReasonReact.string} {x |> E.Float.toString |> ReasonReact.string}
</th> </th>
<th className="px-4 py-2 border "> <th className="px-4 py-2 border ">
{Shape.Mixed.getYIntegral(x, data) {Shape.Mixed.findYIntegral(x, data)
|> E.O.fmap(E.Float.with2DigitsPrecision) |> E.O.fmap(E.Float.with2DigitsPrecision)
|> E.O.default("") |> E.O.default("")
|> ReasonReact.string} |> ReasonReact.string}

View File

@ -1,14 +0,0 @@
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),
} /* discrete: Shape.Discrete.findY(x, t.discrete)*/;
// let getIntegralY = (t: t, x: float): float => {
// continuous: Shape.Continuous.findY(x, t.continuous),

View File

@ -99,14 +99,6 @@ module XYShape = {
let findY = CdfLibrary.Distribution.findY; let findY = CdfLibrary.Distribution.findY;
let findX = CdfLibrary.Distribution.findX; let findX = CdfLibrary.Distribution.findX;
}; };
// let massWithin = (t: t, left: pointInRange, right: pointInRange) => {
// switch (left, right) {
// | (Unbounded, Unbounded) => t |> ySum
// | (Unbounded, X(f)) => t |> integral |> getY(t, 3.0)
// | (X(f), Unbounded) => ySum(t) -. getY(integral(t), f)
// | (X(l), X(r)) => getY(integral(t), r) -. getY(integral(t), l)
// };
// };
module Continuous = { module Continuous = {
let fromArrays = XYShape.fromArrays; let fromArrays = XYShape.fromArrays;
@ -182,13 +174,13 @@ module Mixed = {
discreteProbabilityMassFraction: float, discreteProbabilityMassFraction: float,
}; };
let getY = (t: DistributionTypes.mixedShape, x: float): yPdfPoint => { let findY = (t: DistributionTypes.mixedShape, x: float): yPdfPoint => {
continuous: Continuous.findY(x, t.continuous) |> E.O.some, continuous: Continuous.findY(x, t.continuous) |> E.O.some,
discrete: Discrete.findY(x, t.discrete) |> E.O.some, discrete: Discrete.findY(x, t.discrete) |> E.O.some,
discreteProbabilityMassFraction: t.discreteProbabilityMassFraction, discreteProbabilityMassFraction: t.discreteProbabilityMassFraction,
}; };
let getYIntegral = let findYIntegral =
(x: float, t: DistributionTypes.mixedShape): 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);
@ -208,7 +200,7 @@ module Any = {
let y = (t: t, x: float) => let y = (t: t, x: float) =>
switch (t) { switch (t) {
| Mixed(m) => `mixed(Mixed.getY(m, x)) | Mixed(m) => `mixed(Mixed.findY(m, x))
| Discrete(discreteShape) => `discrete(Discrete.findY(x, discreteShape)) | Discrete(discreteShape) => `discrete(Discrete.findY(x, discreteShape))
| Continuous(continuousShape) => | Continuous(continuousShape) =>
`continuous(Continuous.findY(x, continuousShape)) `continuous(Continuous.findY(x, continuousShape))
@ -216,7 +208,7 @@ module Any = {
let yIntegral = (t: t, x: float) => let yIntegral = (t: t, x: float) =>
switch (t) { switch (t) {
| Mixed(m) => `mixed(Mixed.getYIntegral(x, m)) | Mixed(m) => `mixed(Mixed.findYIntegral(x, m))
| Discrete(discreteShape) => | Discrete(discreteShape) =>
`discrete(Discrete.findIntegralY(x, discreteShape)) `discrete(Discrete.findIntegralY(x, discreteShape))
| Continuous(continuousShape) => | Continuous(continuousShape) =>