Change extrapolation handling in Continuous.combinePointwise to explicit distributionType param
This commit is contained in:
parent
f3922761f4
commit
d9141f6b2b
|
@ -209,30 +209,9 @@ let toDiscretePointMassesFromDiscrete = (s: DistTypes.xyShape): pointMassesWithM
|
|||
let {xs, ys}: XYShape.T.t = s;
|
||||
let n = E.A.length(xs);
|
||||
|
||||
let masses: array(float) = Belt.Array.makeUninitializedUnsafe(n); // doesn't include the fake first and last points
|
||||
let means: array(float) = Belt.Array.makeUninitializedUnsafe(n);
|
||||
let variances: array(float) = Belt.Array.makeUninitializedUnsafe(n);
|
||||
|
||||
for (i in 0 to n - 1) {
|
||||
Belt.Array.set(
|
||||
masses,
|
||||
i,
|
||||
ys[i]
|
||||
) |> ignore;
|
||||
|
||||
Belt.Array.set(
|
||||
means,
|
||||
i,
|
||||
xs[i]
|
||||
) |> ignore;
|
||||
|
||||
Belt.Array.set(
|
||||
variances,
|
||||
i,
|
||||
0.0
|
||||
) |> ignore;
|
||||
();
|
||||
};
|
||||
let masses: array(float) = Belt.Array.makeBy(n, i => ys[i]);
|
||||
let means: array(float) = Belt.Array.makeBy(n, i => xs[i]);
|
||||
let variances: array(float) = Belt.Array.makeBy(n, i => 0.0);
|
||||
|
||||
{n, masses, means, variances};
|
||||
};
|
||||
|
|
|
@ -41,7 +41,7 @@ let combinePointwise =
|
|||
(
|
||||
~integralSumCachesFn=(_, _) => None,
|
||||
~integralCachesFn: (t, t) => option(t) =(_, _) => None,
|
||||
~extrapolation=`UseZero,
|
||||
~distributionType: DistTypes.distributionType = `PDF,
|
||||
fn: (float, float) => float,
|
||||
t1: DistTypes.continuousShape,
|
||||
t2: DistTypes.continuousShape,
|
||||
|
@ -68,6 +68,11 @@ let combinePointwise =
|
|||
| (`Stepwise, `Linear) => (stepwiseToLinear(t1), t2);
|
||||
};
|
||||
|
||||
let extrapolation = switch (distributionType) {
|
||||
| `PDF => `UseZero
|
||||
| `CDF => `UseOutermostPoints
|
||||
};
|
||||
|
||||
let interpolator = XYShape.XtoY.continuousInterpolator(t1.interpolation, extrapolation);
|
||||
|
||||
make(
|
||||
|
|
|
@ -9,6 +9,11 @@ type domain =
|
|||
| RightLimited(domainLimit)
|
||||
| LeftAndRightLimited(domainLimit, domainLimit);
|
||||
|
||||
type distributionType = [
|
||||
| `PDF
|
||||
| `CDF
|
||||
];
|
||||
|
||||
type xyShape = {
|
||||
xs: array(float),
|
||||
ys: array(float),
|
||||
|
|
|
@ -131,7 +131,7 @@ module PointwiseCombination = {
|
|||
`RenderedDist(
|
||||
Shape.combinePointwise(
|
||||
~integralSumCachesFn=(a, b) => Some(a +. b),
|
||||
~integralCachesFn=(a, b) => Some(Continuous.combinePointwise(~extrapolation=`UseOutermostPoints, (+.), a, b)),
|
||||
~integralCachesFn=(a, b) => Some(Continuous.combinePointwise(~distributionType=`CDF, (+.), a, b)),
|
||||
(+.),
|
||||
rs1,
|
||||
rs2,
|
||||
|
|
Loading…
Reference in New Issue
Block a user