Minor CR comments

Value: [1e-6 to 1e-3]
This commit is contained in:
Quinn Dougherty 2022-05-16 15:39:40 -04:00
parent 81b2c74ac8
commit 1d2bb556de

View File

@ -15,9 +15,6 @@ module KLDivergence = {
} }
} }
/*
*/
module LogScoreWithPointResolution = { module LogScoreWithPointResolution = {
let logFn = Js.Math.log let logFn = Js.Math.log
let score = ( let score = (
@ -25,21 +22,21 @@ module LogScoreWithPointResolution = {
~predictionPdf: float => float, ~predictionPdf: float => float,
~answer: float, ~answer: float,
): result<float, Operation.Error.t> => { ): result<float, Operation.Error.t> => {
let numer = answer->predictionPdf let numerator = answer->predictionPdf
if numer < 0.0 { if numerator < 0.0 {
Operation.ComplexNumberError->Error Operation.ComplexNumberError->Error
} else if numer == 0.0 { } else if numerator == 0.0 {
infinity->Ok infinity->Ok
} else { } else {
-.( -.(
switch priorPdf { switch priorPdf {
| None => numer->logFn | None => numerator->logFn
| Some(f) => { | Some(f) => {
let priorDensityOfAnswer = f(answer) let priorDensityOfAnswer = f(answer)
if priorDensityOfAnswer == 0.0 { if priorDensityOfAnswer == 0.0 {
neg_infinity neg_infinity
} else { } else {
(numer /. priorDensityOfAnswer)->logFn (numerator /. priorDensityOfAnswer)->logFn
} }
} }
} }