From 87d6f8d4f64a5adfe9bf2dff165ac4b5ba0b236e Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Fri, 6 May 2022 09:49:42 -0400 Subject: [PATCH] fix: change integrand check order in KL divergence code --- .../Distributions/PointSetDist/PointSetDist_Scoring.res | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist_Scoring.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist_Scoring.res index 7a1f6f61..5a63d6d9 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist_Scoring.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist_Scoring.res @@ -4,10 +4,10 @@ module KLDivergence = { float, Operation.Error.t, > => - if predictionElement == 0.0 { - Error(Operation.NegativeInfinityError) - } else if answerElement == 0.0 { + if answerElement == 0.0 { Ok(0.0) + } else if predictionElement == 0.0 { + Error(Operation.NegativeInfinityError) } else { let quot = predictionElement /. answerElement quot < 0.0 ? Error(Operation.ComplexNumberError) : Ok(answerElement *. logFn(quot))