From 6211d3cfb0daef22070281c8c9557d50305eafdd Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Wed, 4 May 2022 14:55:49 -0400 Subject: [PATCH] Some sorta klDivergence conclusion Value: [1e-6 to 1e-3] --- .../src/rescript/Distributions/PointSetDist/Continuous.res | 2 +- .../Distributions/PointSetDist/PointSetDist_Scoring.res | 2 +- packages/squiggle-lang/src/rescript/Utility/Operation.res | 7 +------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res index c713900f..b9b6b985 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res @@ -281,7 +281,7 @@ module T = Dist({ Ok(0.0) } else { combinePointwise( - PointSetDist_Scoring.KLDivergence.logScore(~eps=MagicNumbers.Epsilon.seven), + PointSetDist_Scoring.KLDivergence.logScore(~eps=MagicNumbers.Epsilon.ten), base, reference, ) 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 d43aeba6..34113edb 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist_Scoring.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist_Scoring.res @@ -6,7 +6,7 @@ module KLDivergence = { if a == 0.0 { Error(Operation.NegativeInfinityError) } else if b == 0.0 { - Error(Operation.DivisionByZeroError) + Ok(b) } else { let quot = a /. b quot < 0.0 ? Error(Operation.ComplexNumberError) : Ok(b *. logFn(quot)) diff --git a/packages/squiggle-lang/src/rescript/Utility/Operation.res b/packages/squiggle-lang/src/rescript/Utility/Operation.res index f124ffcd..3a5f667c 100644 --- a/packages/squiggle-lang/src/rescript/Utility/Operation.res +++ b/packages/squiggle-lang/src/rescript/Utility/Operation.res @@ -164,12 +164,7 @@ module Scale = { | #Multiply => Ok(a *. b) | #Divide => divide(a, b) | #Power => power(a, b) - | #Logarithm => - if a < MagicNumbers.Epsilon.ten { - Error(NegativeInfinityError) - } else { - logarithm(a, b) - } + | #Logarithm => logarithm(a, b) | #LogarithmWithThreshold(eps) => if a < eps { Ok(0.0)