Reapplied truncation changes that previously fixed things

This commit is contained in:
Ozzie Gooen 2020-07-06 19:49:59 +01:00
parent 93f3e12adc
commit 56a9bda82a
2 changed files with 21 additions and 8 deletions

View File

@ -188,14 +188,13 @@ module Continuous = {
let truncate =
(leftCutoff: option(float), rightCutoff: option(float), t: t) => {
let lc = E.O.default(neg_infinity, leftCutoff);
let rc = E.O.default(infinity, rightCutoff);
let truncatedZippedPairs =
t
|> getShape
|> XYShape.T.zip
|> XYShape.Zipped.filterByX(x =>
x >= E.O.default(neg_infinity, leftCutoff)
|| x <= E.O.default(infinity, rightCutoff)
);
|> XYShape.Zipped.filterByX(x => x >= lc && x <= rc);
let eps = (t |> getShape |> XYShape.T.xTotalRange) *. 0.0001;
@ -333,7 +332,12 @@ module Continuous = {
};
let combineAlgebraically =
(~downsample=false, op: ExpressionTypes.algebraicOperation, t1: t, t2: t) => {
(
~downsample=false,
op: ExpressionTypes.algebraicOperation,
t1: t,
t2: t,
) => {
let s1 = t1 |> getShape;
let s2 = t2 |> getShape;
let t1n = s1 |> XYShape.T.length;
@ -342,7 +346,11 @@ module Continuous = {
empty;
} else {
let combinedShape =
AlgebraicShapeCombination.combineShapesContinuousContinuous(op, s1, s2);
AlgebraicShapeCombination.combineShapesContinuousContinuous(
op,
s1,
s2,
);
let combinedIntegralSum =
Common.combineIntegralSums(
(a, b) => Some(a *. b),
@ -840,7 +848,12 @@ module Mixed = {
});
let combineAlgebraically =
(~downsample=false, op: ExpressionTypes.algebraicOperation, t1: t, t2: t)
(
~downsample=false,
op: ExpressionTypes.algebraicOperation,
t1: t,
t2: t,
)
: t => {
// Discrete convolution can cause a huge increase in the number of samples,
// so we'll first downsample.

View File

@ -147,7 +147,7 @@ module Truncate = {
| Ok(`RenderedDist(rs)) => {
let truncatedShape =
rs |> Distributions.Shape.T.truncate(leftCutoff, rightCutoff);
Ok(`RenderedDist(rs));
Ok(`RenderedDist(truncatedShape));
}
| Error(e1) => Error(e1)
| _ => Error("Could not truncate distribution.")