**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
|
C.LogScore.distEstimateScalarAnswer(estimate, answer)->run(~env)->toFloatR
|
||||||
let distEstimateScalarAnswerWithPrior = (~env, estimate, answer, prior) =>
|
let distEstimateScalarAnswerWithPrior = (~env, estimate, answer, prior) =>
|
||||||
C.LogScore.distEstimateScalarAnswerWithPrior(estimate, answer, prior)->run(~env)->toFloatR
|
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 toPointSet = (~env, dist) => C.toPointSet(dist)->run(~env)->toDistR
|
||||||
let toSampleSet = (~env, dist, n) => C.toSampleSet(dist, n)->run(~env)->toDistR
|
let toSampleSet = (~env, dist, n) => C.toSampleSet(dist, n)->run(~env)->toDistR
|
||||||
|
|
|
@ -83,24 +83,6 @@ module Constructors: {
|
||||||
float,
|
float,
|
||||||
DistributionTypes.DistributionOperation.genericDistOrScalar,
|
DistributionTypes.DistributionOperation.genericDistOrScalar,
|
||||||
) => result<float, error>
|
) => 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
|
@genType
|
||||||
let toPointSet: (~env: env, genericDist) => result<genericDist, error>
|
let toPointSet: (~env: env, genericDist) => result<genericDist, error>
|
||||||
|
|
|
@ -194,22 +194,6 @@ module Constructors = {
|
||||||
ToScore(LogScore(Score_Scalar(answer), Some(prior))),
|
ToScore(LogScore(Score_Scalar(answer), Some(prior))),
|
||||||
estimate,
|
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 scaleMultiply = (dist, n): t => FromDist(ToDist(Scale(#Multiply, n)), dist)
|
||||||
let scalePower = (dist, n): t => FromDist(ToDist(Scale(#Power, n)), dist)
|
let scalePower = (dist, n): t => FromDist(ToDist(Scale(#Power, n)), dist)
|
||||||
|
|
|
@ -160,7 +160,7 @@ module Score = {
|
||||||
switch (esti, answ, prior') {
|
switch (esti, answ, prior') {
|
||||||
| (Score_Dist(esti'), Score_Dist(answ'), None) =>
|
| (Score_Dist(esti'), Score_Dist(answ'), None) =>
|
||||||
twoDists(~toPointSetFn, esti', answ')->E.R2.fmap(((esti'', answ'')) =>
|
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'')))) =>
|
| (Score_Dist(esti'), Score_Dist(answ'), Some(Ok(PSDist(prior'')))) =>
|
||||||
twoDists(~toPointSetFn, esti', answ')->E.R2.fmap(((esti'', answ'')) =>
|
twoDists(~toPointSetFn, esti', answ')->E.R2.fmap(((esti'', answ'')) =>
|
||||||
|
@ -168,7 +168,7 @@ module Score = {
|
||||||
estimate: esti'',
|
estimate: esti'',
|
||||||
answer: answ'',
|
answer: answ'',
|
||||||
prior: Some(prior''),
|
prior: Some(prior''),
|
||||||
}->PointSetDist_Scoring.DistEstimateDistAnswer
|
}->PointSetDist_Scoring.DistAnswer
|
||||||
)
|
)
|
||||||
| (Score_Dist(_), _, Some(Ok(PSScalar(_)))) => DistributionTypes.Unreachable->Error
|
| (Score_Dist(_), _, Some(Ok(PSScalar(_)))) => DistributionTypes.Unreachable->Error
|
||||||
| (Score_Dist(esti'), Score_Scalar(answ'), None) =>
|
| (Score_Dist(esti'), Score_Scalar(answ'), None) =>
|
||||||
|
@ -177,7 +177,7 @@ module Score = {
|
||||||
estimate: esti'',
|
estimate: esti'',
|
||||||
answer: answ',
|
answer: answ',
|
||||||
prior: None,
|
prior: None,
|
||||||
}->PointSetDist_Scoring.DistEstimateScalarAnswer
|
}->PointSetDist_Scoring.ScalarAnswer
|
||||||
)
|
)
|
||||||
| (Score_Dist(esti'), Score_Scalar(answ'), Some(Ok(PSDist(prior'')))) =>
|
| (Score_Dist(esti'), Score_Scalar(answ'), Some(Ok(PSDist(prior'')))) =>
|
||||||
toPointSetFn(esti')->E.R2.fmap(esti'' =>
|
toPointSetFn(esti')->E.R2.fmap(esti'' =>
|
||||||
|
@ -185,7 +185,7 @@ module Score = {
|
||||||
estimate: esti'',
|
estimate: esti'',
|
||||||
answer: answ',
|
answer: answ',
|
||||||
prior: Some(prior''),
|
prior: Some(prior''),
|
||||||
}->PointSetDist_Scoring.DistEstimateScalarAnswer
|
}->PointSetDist_Scoring.ScalarAnswer
|
||||||
)
|
)
|
||||||
| (Score_Scalar(_), Score_Dist(_), None) => NotYetImplemented->Error
|
| (Score_Scalar(_), Score_Dist(_), None) => NotYetImplemented->Error
|
||||||
| (Score_Scalar(_), Score_Dist(_), Some(Ok(PSScalar(_)))) => NotYetImplemented->Error
|
| (Score_Scalar(_), Score_Dist(_), Some(Ok(PSScalar(_)))) => NotYetImplemented->Error
|
||||||
|
|
|
@ -4,8 +4,8 @@ type scalar = float
|
||||||
type score = float
|
type score = float
|
||||||
type abstractScoreArgs<'a, 'b> = {estimate: 'a, answer: 'b, prior: option<'a>}
|
type abstractScoreArgs<'a, 'b> = {estimate: 'a, answer: 'b, prior: option<'a>}
|
||||||
type scoreArgs =
|
type scoreArgs =
|
||||||
| DistEstimateDistAnswer(abstractScoreArgs<pointSetDist, pointSetDist>)
|
| DistAnswer(abstractScoreArgs<pointSetDist, pointSetDist>)
|
||||||
| DistEstimateScalarAnswer(abstractScoreArgs<pointSetDist, scalar>)
|
| ScalarAnswer(abstractScoreArgs<pointSetDist, scalar>)
|
||||||
|
|
||||||
let logFn = Js.Math.log // base e
|
let logFn = Js.Math.log // base e
|
||||||
let minusScaledLogOfQuotient = (~esti, ~answ): result<float, Operation.Error.t> => {
|
let minusScaledLogOfQuotient = (~esti, ~answ): result<float, Operation.Error.t> => {
|
||||||
|
@ -139,12 +139,11 @@ let logScore = (args: scoreArgs, ~combineFn, ~integrateFn, ~toMixedFn): result<
|
||||||
Operation.Error.t,
|
Operation.Error.t,
|
||||||
> =>
|
> =>
|
||||||
switch args {
|
switch args {
|
||||||
| DistEstimateDistAnswer({estimate, answer, prior: None}) =>
|
| DistAnswer({estimate, answer, prior: None}) =>
|
||||||
WithDistAnswer.sum(~estimate, ~answer, ~integrateFn, ~combineFn, ~toMixedFn)
|
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)
|
WithDistAnswer.sumWithPrior(~estimate, ~answer, ~prior, ~integrateFn, ~combineFn, ~toMixedFn)
|
||||||
| DistEstimateScalarAnswer({estimate, answer, prior: None}) =>
|
| ScalarAnswer({estimate, answer, prior: None}) => WithScalarAnswer.score(~estimate, ~answer)
|
||||||
WithScalarAnswer.score(~estimate, ~answer)
|
| ScalarAnswer({estimate, answer, prior: Some(prior)}) =>
|
||||||
| DistEstimateScalarAnswer({estimate, answer, prior: Some(prior)}) =>
|
|
||||||
WithScalarAnswer.scoreWithPrior(~estimate, ~answer, ~prior)
|
WithScalarAnswer.scoreWithPrior(~estimate, ~answer, ~prior)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user