make lint happy

Value: [1e-9 to 1e-5]
This commit is contained in:
Quinn Dougherty 2022-05-02 11:55:42 -04:00
parent e2762a0f62
commit d595285078
6 changed files with 14 additions and 10 deletions

View File

@ -164,7 +164,7 @@ module T = Dist({
} }
let integralEndY = (t: t) => t.integralSumCache |> E.O.default(t |> integral |> Continuous.lastY) let integralEndY = (t: t) => t.integralSumCache |> E.O.default(t |> integral |> Continuous.lastY)
let integralEndYResult = (t: t) => t -> integralEndY -> Ok let integralEndYResult = (t: t) => t->integralEndY->Ok
let minX = shapeFn(XYShape.T.minX) let minX = shapeFn(XYShape.T.minX)
let maxX = shapeFn(XYShape.T.maxX) let maxX = shapeFn(XYShape.T.maxX)
let toDiscreteProbabilityMassFraction = _ => 1.0 let toDiscreteProbabilityMassFraction = _ => 1.0
@ -230,8 +230,9 @@ module T = Dist({
} }
let logScore = (base: t, reference: t) => { let logScore = (base: t, reference: t) => {
combinePointwise(~fn=PointSetDist_Scoring.LogScoring.logScore, base, reference) combinePointwise(~fn=PointSetDist_Scoring.LogScoring.logScore, base, reference) |> E.R2.bind(
|> E.R2.bind(integralEndYResult) integralEndYResult,
)
// |> (r => Ok(r)) // |> (r => Ok(r))
} }
}) })

View File

@ -33,7 +33,7 @@ module type dist = {
let mean: t => float let mean: t => float
let variance: t => float let variance: t => float
let logScore: (t,t) => result<float, Operation.Error.t> let logScore: (t, t) => result<float, Operation.Error.t>
} }
module Dist = (T: dist) => { module Dist = (T: dist) => {

View File

@ -44,7 +44,11 @@ let combinePointwise = (
t2: t, t2: t,
): result<t, 'e> => { ): result<t, 'e> => {
let reducedDiscrete = let reducedDiscrete =
[t1, t2] |> E.A.fmap(toDiscrete) |> E.A.O.concatSomes |> Discrete.reduce(~integralSumCachesFn, fn) |> E.R.toExn("foo") [t1, t2]
|> E.A.fmap(toDiscrete)
|> E.A.O.concatSomes
|> Discrete.reduce(~integralSumCachesFn, fn)
|> E.R.toExn("foo")
let reducedContinuous = let reducedContinuous =
[t1, t2] [t1, t2]

View File

@ -4,4 +4,4 @@ module LogScoring = {
let logScore = (a: float, b: float): result<float, Operation.Error.t> => Ok( let logScore = (a: float, b: float): result<float, Operation.Error.t> => Ok(
Js.Math.log2(Js.Math.abs_float(a /. b)), Js.Math.log2(Js.Math.abs_float(a /. b)),
) )
} }

View File

@ -212,9 +212,8 @@ let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option<
a, a,
)->Some )->Some
| ("normalize", [EvDistribution(dist)]) => Helpers.toDistFn(Normalize, dist) | ("normalize", [EvDistribution(dist)]) => Helpers.toDistFn(Normalize, dist)
| ("logScore", [EvDistribution(a), EvDistribution(b)]) => Some( | ("logScore", [EvDistribution(a), EvDistribution(b)]) =>
runGenericOperation(FromDist(ToScore(LogScore(b)), a)), Some(runGenericOperation(FromDist(ToScore(LogScore(b)), a)))
)
| ("isNormalized", [EvDistribution(dist)]) => Helpers.toBoolFn(IsNormalized, dist) | ("isNormalized", [EvDistribution(dist)]) => Helpers.toBoolFn(IsNormalized, dist)
| ("toPointSet", [EvDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist) | ("toPointSet", [EvDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist)
| ("scaleLog", [EvDistribution(dist)]) => | ("scaleLog", [EvDistribution(dist)]) =>

View File

@ -96,7 +96,7 @@ module T = {
let fromZippedArray = (pairs: array<(float, float)>): t => pairs |> Belt.Array.unzip |> fromArray let fromZippedArray = (pairs: array<(float, float)>): t => pairs |> Belt.Array.unzip |> fromArray
let equallyDividedXs = (t: t, newLength) => E.A.Floats.range(minX(t), maxX(t), newLength) let equallyDividedXs = (t: t, newLength) => E.A.Floats.range(minX(t), maxX(t), newLength)
let toJs = (t: t) => {"xs": t.xs, "ys": t.ys} let toJs = (t: t) => {"xs": t.xs, "ys": t.ys}
let filterYValues = (fn, t: t): t => t |> zip |> E.A.filter(((_,y)) => fn(y)) |> fromZippedArray let filterYValues = (fn, t: t): t => t |> zip |> E.A.filter(((_, y)) => fn(y)) |> fromZippedArray
module Validator = { module Validator = {
let fnName = "XYShape validate" let fnName = "XYShape validate"