From 8cb138b84aaf3ed2ecee5408ff1d7ad0ce1ad932 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Sat, 23 Apr 2022 17:48:00 -0400 Subject: [PATCH] Fix convolution for negative multiplication --- .../PointSetDist/AlgebraicShapeCombination.res | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res index fd7871cd..d6ff1d31 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res @@ -230,13 +230,12 @@ let combineShapesContinuousDiscrete = ( i, ( fn(continuousShape.xs[i], discreteShape.xs[j]), - continuousShape.ys[i] *. discreteShape.ys[j] /. discreteShape.xs[j], + continuousShape.ys[i] *. discreteShape.ys[j] /. Js.Math.abs_float(discreteShape.xs[j]), ), ) |> ignore () } Belt.Array.set(outXYShapes, j, dxyShape) |> ignore - () } } @@ -244,12 +243,11 @@ let combineShapesContinuousDiscrete = ( |> E.A.fmap(XYShape.T.fromZippedArray) |> E.A.fold_left( (acc, x) => - XYShape.PointwiseCombination.combine( - (a, b) => Ok(a +. b), + XYShape.PointwiseCombination.addCombine( XYShape.XtoY.continuousInterpolator(#Linear, #UseZero), acc, x, - )->E.R.toExn("Error, unexpected failure", _), + ), XYShape.T.empty, ) }