backed out of mutually recursive dispatch
Value: [1e-5 to 1e-3]
This commit is contained in:
parent
8710248a22
commit
30ab62e9b8
|
@ -165,7 +165,7 @@ module Helpers = {
|
||||||
let constructNonNormalizedPointSet = (
|
let constructNonNormalizedPointSet = (
|
||||||
~supportOf: DistributionTypes.genericDist,
|
~supportOf: DistributionTypes.genericDist,
|
||||||
fn: float => float,
|
fn: float => float,
|
||||||
env: DistributionOperation.env
|
env: DistributionOperation.env,
|
||||||
): DistributionTypes.genericDist => {
|
): DistributionTypes.genericDist => {
|
||||||
let cdf = x => toFloatFn(#Cdf(x), supportOf, ~env)
|
let cdf = x => toFloatFn(#Cdf(x), supportOf, ~env)
|
||||||
let leftEndpoint = cdf(MagicNumbers.Epsilon.ten)
|
let leftEndpoint = cdf(MagicNumbers.Epsilon.ten)
|
||||||
|
@ -216,7 +216,7 @@ module SymbolicConstructors = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let rec dispatchToGenericOutput = (
|
let dispatchToGenericOutput = (
|
||||||
call: ExpressionValue.functionCall,
|
call: ExpressionValue.functionCall,
|
||||||
env: DistributionOperation.env,
|
env: DistributionOperation.env,
|
||||||
): option<DistributionOperation.outputType> => {
|
): option<DistributionOperation.outputType> => {
|
||||||
|
@ -243,7 +243,8 @@ let rec dispatchToGenericOutput = (
|
||||||
| ("mean", [EvDistribution(dist)]) => Helpers.toFloatFn(#Mean, dist, ~env)
|
| ("mean", [EvDistribution(dist)]) => Helpers.toFloatFn(#Mean, dist, ~env)
|
||||||
| ("integralSum", [EvDistribution(dist)]) => Helpers.toFloatFn(#IntegralSum, dist, ~env)
|
| ("integralSum", [EvDistribution(dist)]) => Helpers.toFloatFn(#IntegralSum, dist, ~env)
|
||||||
| ("toString", [EvDistribution(dist)]) => Helpers.toStringFn(ToString, dist, ~env)
|
| ("toString", [EvDistribution(dist)]) => Helpers.toStringFn(ToString, dist, ~env)
|
||||||
| ("toSparkline", [EvDistribution(dist)]) => Helpers.toStringFn(ToSparkline(MagicNumbers.Environment.sparklineLength), dist, ~env)
|
| ("toSparkline", [EvDistribution(dist)]) =>
|
||||||
|
Helpers.toStringFn(ToSparkline(MagicNumbers.Environment.sparklineLength), dist, ~env)
|
||||||
| ("toSparkline", [EvDistribution(dist), EvNumber(n)]) =>
|
| ("toSparkline", [EvDistribution(dist), EvNumber(n)]) =>
|
||||||
Helpers.toStringFn(ToSparkline(Belt.Float.toInt(n)), dist, ~env)
|
Helpers.toStringFn(ToSparkline(Belt.Float.toInt(n)), dist, ~env)
|
||||||
| ("exp", [EvDistribution(a)]) =>
|
| ("exp", [EvDistribution(a)]) =>
|
||||||
|
@ -266,26 +267,16 @@ let rec dispatchToGenericOutput = (
|
||||||
"logScoreWithPointResolution",
|
"logScoreWithPointResolution",
|
||||||
[EvDistribution(prediction), EvDistribution(Symbolic(#Float(answer))), EvDistribution(prior)],
|
[EvDistribution(prediction), EvDistribution(Symbolic(#Float(answer))), EvDistribution(prior)],
|
||||||
) =>
|
) =>
|
||||||
DistributionOperation.run(FromDist(ToScore(LogScore(answer, prior->Some)), prediction), ~env)->Some
|
DistributionOperation.run(
|
||||||
|
FromDist(ToScore(LogScore(answer, prior->Some)), prediction),
|
||||||
|
~env,
|
||||||
|
)->Some
|
||||||
| ("logScoreWithPointResolution", [EvDistribution(prediction), EvNumber(answer)])
|
| ("logScoreWithPointResolution", [EvDistribution(prediction), EvNumber(answer)])
|
||||||
| (
|
| (
|
||||||
"logScoreWithPointResolution",
|
"logScoreWithPointResolution",
|
||||||
[EvDistribution(prediction), EvDistribution(Symbolic(#Float(answer)))],
|
[EvDistribution(prediction), EvDistribution(Symbolic(#Float(answer)))],
|
||||||
) =>
|
) =>
|
||||||
DistributionOperation.run(FromDist(ToScore(LogScore(answer, None)), prediction), ~env)->Some
|
DistributionOperation.run(FromDist(ToScore(LogScore(answer, None)), prediction), ~env)->Some
|
||||||
| ("logScore", [EvRecord(r)]) =>
|
|
||||||
[
|
|
||||||
recurRecordArgs(
|
|
||||||
"logScoreWithPointResolution",
|
|
||||||
["estimate", "answer", "prior"],
|
|
||||||
r,
|
|
||||||
env,
|
|
||||||
),
|
|
||||||
recurRecordArgs("klDivergence", ["estimate", "answer"], r, env),
|
|
||||||
recurRecordArgs("logScoreWithPointResolution", ["estimate", "answer"], r, env),
|
|
||||||
]->E.A.O.firstSome
|
|
||||||
| ("increment", [EvNumber(x)]) => (x +. 1.0)->DistributionOperation.Float->Some // this tests recurRecordArgs function
|
|
||||||
| ("increment", [EvRecord(r)]) => recurRecordArgs("increment", ["incrementee"], r, env)
|
|
||||||
| ("isNormalized", [EvDistribution(dist)]) => Helpers.toBoolFn(IsNormalized, dist, ~env)
|
| ("isNormalized", [EvDistribution(dist)]) => Helpers.toBoolFn(IsNormalized, dist, ~env)
|
||||||
| ("toPointSet", [EvDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist, ~env)
|
| ("toPointSet", [EvDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist, ~env)
|
||||||
| ("scaleLog", [EvDistribution(dist)]) =>
|
| ("scaleLog", [EvDistribution(dist)]) =>
|
||||||
|
@ -372,16 +363,6 @@ let rec dispatchToGenericOutput = (
|
||||||
| _ => None
|
| _ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
and recurRecordArgs = (
|
|
||||||
fnName: string,
|
|
||||||
argNames: array<string>,
|
|
||||||
args: ExpressionValue.record,
|
|
||||||
env: DistributionOperation.env,
|
|
||||||
): option<DistributionOperation.outputType> =>
|
|
||||||
// argNames -> E.A2.fmap(x => Js.Dict.get(args, x)) -> E.A.O.arrSomeToSomeArr -> E.O.bind(a => dispatchToGenericOutput((fnName, a), _environment))
|
|
||||||
argNames
|
|
||||||
->E.A2.fmap(x => Js.Dict.unsafeGet(args, x))
|
|
||||||
->(a => dispatchToGenericOutput((fnName, a), env))
|
|
||||||
|
|
||||||
let genericOutputToReducerValue = (o: DistributionOperation.outputType): result<
|
let genericOutputToReducerValue = (o: DistributionOperation.outputType): result<
|
||||||
expressionValue,
|
expressionValue,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user