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

View File

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