Merge pull request #358 from quantified-uncertainty/negative-multiplication-convolution

Fix convolution for negative multiplication
This commit is contained in:
Ozzie Gooen 2022-04-23 18:08:51 -04:00 committed by GitHub
commit 4e77448f02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -230,13 +230,12 @@ let combineShapesContinuousDiscrete = (
i, i,
( (
fn(continuousShape.xs[i], discreteShape.xs[j]), 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 ) |> ignore
() ()
} }
Belt.Array.set(outXYShapes, j, dxyShape) |> ignore Belt.Array.set(outXYShapes, j, dxyShape) |> ignore
()
} }
} }
@ -244,12 +243,11 @@ let combineShapesContinuousDiscrete = (
|> E.A.fmap(XYShape.T.fromZippedArray) |> E.A.fmap(XYShape.T.fromZippedArray)
|> E.A.fold_left( |> E.A.fold_left(
(acc, x) => (acc, x) =>
XYShape.PointwiseCombination.combine( XYShape.PointwiseCombination.addCombine(
(a, b) => Ok(a +. b),
XYShape.XtoY.continuousInterpolator(#Linear, #UseZero), XYShape.XtoY.continuousInterpolator(#Linear, #UseZero),
acc, acc,
x, x,
)->E.R.toExn("Error, unexpected failure", _), ),
XYShape.T.empty, XYShape.T.empty,
) )
} }