**most** comments, might do something with polymorphic variants so that types are more truthful next, but might not
This commit is contained in:
parent
9225710d2d
commit
4858aa9fe5
|
@ -278,14 +278,6 @@ module Constructors = {
|
|||
C.LogScore.distEstimateScalarAnswer(estimate, answer)->run(~env)->toFloatR
|
||||
let distEstimateScalarAnswerWithPrior = (~env, estimate, answer, prior) =>
|
||||
C.LogScore.distEstimateScalarAnswerWithPrior(estimate, answer, prior)->run(~env)->toFloatR
|
||||
let scalarEstimateDistAnswer = (~env, estimate, answer) =>
|
||||
C.LogScore.scalarEstimateDistAnswer(estimate, answer)->run(~env)->toFloatR
|
||||
let scalarEstimateDistAnswerWithPrior = (~env, estimate, answer, prior) =>
|
||||
C.LogScore.scalarEstimateDistAnswerWithPrior(estimate, answer, prior)->run(~env)->toFloatR
|
||||
let scalarEstimateScalarAnswer = (~env, estimate, answer) =>
|
||||
C.LogScore.scalarEstimateScalarAnswer(estimate, answer)->run(~env)->toFloatR
|
||||
let scalarEstimateScalarAnswerWithPrior = (~env, estimate, answer, prior) =>
|
||||
C.LogScore.scalarEstimateScalarAnswerWithPrior(estimate, answer, prior)->run(~env)->toFloatR
|
||||
}
|
||||
let toPointSet = (~env, dist) => C.toPointSet(dist)->run(~env)->toDistR
|
||||
let toSampleSet = (~env, dist, n) => C.toSampleSet(dist, n)->run(~env)->toDistR
|
||||
|
|
|
@ -83,24 +83,6 @@ module Constructors: {
|
|||
float,
|
||||
DistributionTypes.DistributionOperation.genericDistOrScalar,
|
||||
) => result<float, error>
|
||||
@genType
|
||||
let scalarEstimateDistAnswer: (~env: env, float, genericDist) => result<float, error>
|
||||
@genType
|
||||
let scalarEstimateDistAnswerWithPrior: (
|
||||
~env: env,
|
||||
float,
|
||||
genericDist,
|
||||
DistributionTypes.DistributionOperation.genericDistOrScalar,
|
||||
) => result<float, error>
|
||||
@genType
|
||||
let scalarEstimateScalarAnswer: (~env: env, float, float) => result<float, error>
|
||||
@genType
|
||||
let scalarEstimateScalarAnswerWithPrior: (
|
||||
~env: env,
|
||||
float,
|
||||
float,
|
||||
DistributionTypes.DistributionOperation.genericDistOrScalar,
|
||||
) => result<float, error>
|
||||
}
|
||||
@genType
|
||||
let toPointSet: (~env: env, genericDist) => result<genericDist, error>
|
||||
|
|
|
@ -194,22 +194,6 @@ module Constructors = {
|
|||
ToScore(LogScore(Score_Scalar(answer), Some(prior))),
|
||||
estimate,
|
||||
)
|
||||
let scalarEstimateDistAnswer = (estimate, answer): t => FromFloat(
|
||||
ToScore(LogScore(Score_Dist(answer), None)),
|
||||
estimate,
|
||||
)
|
||||
let scalarEstimateDistAnswerWithPrior = (estimate, answer, prior): t => FromFloat(
|
||||
ToScore(LogScore(Score_Dist(answer), Some(prior))),
|
||||
estimate,
|
||||
)
|
||||
let scalarEstimateScalarAnswer = (estimate, answer): t => FromFloat(
|
||||
ToScore(LogScore(Score_Scalar(answer), None)),
|
||||
estimate,
|
||||
)
|
||||
let scalarEstimateScalarAnswerWithPrior = (estimate, answer, prior): t => FromFloat(
|
||||
ToScore(LogScore(Score_Scalar(answer), Some(prior))),
|
||||
estimate,
|
||||
)
|
||||
}
|
||||
let scaleMultiply = (dist, n): t => FromDist(ToDist(Scale(#Multiply, n)), dist)
|
||||
let scalePower = (dist, n): t => FromDist(ToDist(Scale(#Power, n)), dist)
|
||||
|
|
|
@ -160,7 +160,7 @@ module Score = {
|
|||
switch (esti, answ, prior') {
|
||||
| (Score_Dist(esti'), Score_Dist(answ'), None) =>
|
||||
twoDists(~toPointSetFn, esti', answ')->E.R2.fmap(((esti'', answ'')) =>
|
||||
{estimate: esti'', answer: answ'', prior: None}->PointSetDist_Scoring.DistEstimateDistAnswer
|
||||
{estimate: esti'', answer: answ'', prior: None}->PointSetDist_Scoring.DistAnswer
|
||||
)
|
||||
| (Score_Dist(esti'), Score_Dist(answ'), Some(Ok(PSDist(prior'')))) =>
|
||||
twoDists(~toPointSetFn, esti', answ')->E.R2.fmap(((esti'', answ'')) =>
|
||||
|
@ -168,7 +168,7 @@ module Score = {
|
|||
estimate: esti'',
|
||||
answer: answ'',
|
||||
prior: Some(prior''),
|
||||
}->PointSetDist_Scoring.DistEstimateDistAnswer
|
||||
}->PointSetDist_Scoring.DistAnswer
|
||||
)
|
||||
| (Score_Dist(_), _, Some(Ok(PSScalar(_)))) => DistributionTypes.Unreachable->Error
|
||||
| (Score_Dist(esti'), Score_Scalar(answ'), None) =>
|
||||
|
@ -177,7 +177,7 @@ module Score = {
|
|||
estimate: esti'',
|
||||
answer: answ',
|
||||
prior: None,
|
||||
}->PointSetDist_Scoring.DistEstimateScalarAnswer
|
||||
}->PointSetDist_Scoring.ScalarAnswer
|
||||
)
|
||||
| (Score_Dist(esti'), Score_Scalar(answ'), Some(Ok(PSDist(prior'')))) =>
|
||||
toPointSetFn(esti')->E.R2.fmap(esti'' =>
|
||||
|
@ -185,7 +185,7 @@ module Score = {
|
|||
estimate: esti'',
|
||||
answer: answ',
|
||||
prior: Some(prior''),
|
||||
}->PointSetDist_Scoring.DistEstimateScalarAnswer
|
||||
}->PointSetDist_Scoring.ScalarAnswer
|
||||
)
|
||||
| (Score_Scalar(_), Score_Dist(_), None) => NotYetImplemented->Error
|
||||
| (Score_Scalar(_), Score_Dist(_), Some(Ok(PSScalar(_)))) => NotYetImplemented->Error
|
||||
|
|
|
@ -4,8 +4,8 @@ type scalar = float
|
|||
type score = float
|
||||
type abstractScoreArgs<'a, 'b> = {estimate: 'a, answer: 'b, prior: option<'a>}
|
||||
type scoreArgs =
|
||||
| DistEstimateDistAnswer(abstractScoreArgs<pointSetDist, pointSetDist>)
|
||||
| DistEstimateScalarAnswer(abstractScoreArgs<pointSetDist, scalar>)
|
||||
| DistAnswer(abstractScoreArgs<pointSetDist, pointSetDist>)
|
||||
| ScalarAnswer(abstractScoreArgs<pointSetDist, scalar>)
|
||||
|
||||
let logFn = Js.Math.log // base e
|
||||
let minusScaledLogOfQuotient = (~esti, ~answ): result<float, Operation.Error.t> => {
|
||||
|
@ -139,12 +139,11 @@ let logScore = (args: scoreArgs, ~combineFn, ~integrateFn, ~toMixedFn): result<
|
|||
Operation.Error.t,
|
||||
> =>
|
||||
switch args {
|
||||
| DistEstimateDistAnswer({estimate, answer, prior: None}) =>
|
||||
| DistAnswer({estimate, answer, prior: None}) =>
|
||||
WithDistAnswer.sum(~estimate, ~answer, ~integrateFn, ~combineFn, ~toMixedFn)
|
||||
| DistEstimateDistAnswer({estimate, answer, prior: Some(prior)}) =>
|
||||
| DistAnswer({estimate, answer, prior: Some(prior)}) =>
|
||||
WithDistAnswer.sumWithPrior(~estimate, ~answer, ~prior, ~integrateFn, ~combineFn, ~toMixedFn)
|
||||
| DistEstimateScalarAnswer({estimate, answer, prior: None}) =>
|
||||
WithScalarAnswer.score(~estimate, ~answer)
|
||||
| DistEstimateScalarAnswer({estimate, answer, prior: Some(prior)}) =>
|
||||
| ScalarAnswer({estimate, answer, prior: None}) => WithScalarAnswer.score(~estimate, ~answer)
|
||||
| ScalarAnswer({estimate, answer, prior: Some(prior)}) =>
|
||||
WithScalarAnswer.scoreWithPrior(~estimate, ~answer, ~prior)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user