removed \TwoScalars\
material
This commit is contained in:
parent
29cf1cebb2
commit
acb0d3b9ee
|
@ -1,90 +0,0 @@
|
||||||
open Jest
|
|
||||||
open Expect
|
|
||||||
open GenericDist_Fixtures
|
|
||||||
exception ScoreFailed
|
|
||||||
|
|
||||||
describe("TwoScalars: scalar -> scalar -> score", () => {
|
|
||||||
test("score: infinity", () => {
|
|
||||||
let scalar1 = 1.0 // 100% of probability mass 1.0
|
|
||||||
let scalar2 = 2.0 // 100% of probability mass to 2.0
|
|
||||||
let score = PointSetDist_Scoring.TwoScalars.score(~estimate=scalar1, ~answer=scalar2)
|
|
||||||
switch score {
|
|
||||||
| Ok(x) => x->expect->toEqual(infinity)
|
|
||||||
| _ => raise(MixtureFailed)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
test("score: 0.0", () => {
|
|
||||||
let scalar1 = 1.5 // 100% of probability mass 1.5
|
|
||||||
let scalar2 = 1.5 // 100% of probability mass to 1.5
|
|
||||||
let score = PointSetDist_Scoring.TwoScalars.score(~estimate=scalar1, ~answer=scalar2)
|
|
||||||
switch score {
|
|
||||||
| Ok(x) => x->expect->toEqual(0.0)
|
|
||||||
| _ => raise(MixtureFailed)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
test("scoreWithPrior: minus infinity", () => {
|
|
||||||
let scalar1 = 1.5 // 100% of probability mass 1.5
|
|
||||||
let scalar2 = 1.5 // 100% of probability mass to 1.5
|
|
||||||
let scalar3 = 1.0 // 100% of probability mass to 1.0
|
|
||||||
|
|
||||||
let score = PointSetDist_Scoring.TwoScalars.scoreWithPrior(
|
|
||||||
~estimate=scalar1,
|
|
||||||
~answer=scalar2,
|
|
||||||
~prior=scalar3,
|
|
||||||
)
|
|
||||||
switch score {
|
|
||||||
| Ok(x) => x->expect->toEqual(-.infinity)
|
|
||||||
| _ => raise(MixtureFailed)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
test("scoreWithPrior: 0.0", () => {
|
|
||||||
let scalar1 = 1.5 // 100% of probability mass 1.5
|
|
||||||
let scalar2 = 1.5 // 100% of probability mass to 1.5
|
|
||||||
let scalar3 = 1.5 // 100% of probability mass to 1.5
|
|
||||||
|
|
||||||
let score = PointSetDist_Scoring.TwoScalars.scoreWithPrior(
|
|
||||||
~estimate=scalar1,
|
|
||||||
~answer=scalar2,
|
|
||||||
~prior=scalar3,
|
|
||||||
)
|
|
||||||
switch score {
|
|
||||||
| Ok(x) => x->expect->toEqual(0.0)
|
|
||||||
| _ => raise(ScoreFailed)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
test("scoreWithPrior: really dumb forecasters", () => {
|
|
||||||
let scalar1 = 1.0 // 100% of probability mass 1.0
|
|
||||||
let scalar2 = 1.5 // 100% of probability mass to 1.5
|
|
||||||
let scalar3 = 1.0 // 100% of probability mass to 1.0
|
|
||||||
|
|
||||||
let score = PointSetDist_Scoring.TwoScalars.scoreWithPrior(
|
|
||||||
~estimate=scalar1,
|
|
||||||
~answer=scalar2,
|
|
||||||
~prior=scalar3,
|
|
||||||
)
|
|
||||||
switch score {
|
|
||||||
| Ok(x) => x->expect->toEqual(infinity -. infinity) // "Error: Really dumb forecasters"
|
|
||||||
| _ => raise(ScoreFailed)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
test("scoreWithPrior: 0.0", () => {
|
|
||||||
let scalar1 = 1.0 // 100% of probability mass 1.0
|
|
||||||
let scalar2 = 1.0 // 100% of probability mass to 1.0
|
|
||||||
let scalar3 = 1.0 // 100% of probability mass to 1.0
|
|
||||||
|
|
||||||
let score = PointSetDist_Scoring.TwoScalars.scoreWithPrior(
|
|
||||||
~estimate=scalar1,
|
|
||||||
~answer=scalar2,
|
|
||||||
~prior=scalar3,
|
|
||||||
)
|
|
||||||
switch score {
|
|
||||||
| Ok(x) => x->expect->toEqual(0.0)
|
|
||||||
| _ => raise(ScoreFailed)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
|
@ -190,14 +190,7 @@ module Score = {
|
||||||
| (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
|
||||||
| (Score_Scalar(_), _, Some(Ok(PSDist(_)))) => DistributionTypes.Unreachable->Error
|
| (Score_Scalar(_), _, Some(Ok(PSDist(_)))) => DistributionTypes.Unreachable->Error
|
||||||
| (Score_Scalar(esti'), Score_Scalar(answ'), None) =>
|
| (Score_Scalar(_), Score_Scalar(_), _) => NotYetImplemented->Error
|
||||||
{estimate: esti', answer: answ', prior: None}
|
|
||||||
->PointSetDist_Scoring.ScalarEstimateScalarAnswer
|
|
||||||
->Ok
|
|
||||||
| (Score_Scalar(esti'), Score_Scalar(answ'), Some(Ok(PSScalar(prior'')))) =>
|
|
||||||
{estimate: esti', answer: answ', prior: prior''->Some}
|
|
||||||
->PointSetDist_Scoring.ScalarEstimateScalarAnswer
|
|
||||||
->Ok
|
|
||||||
| (_, _, Some(Error(err))) => err->Error
|
| (_, _, Some(Error(err))) => err->Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ type abstractScoreArgs<'a, 'b> = {estimate: 'a, answer: 'b, prior: option<'a>}
|
||||||
type scoreArgs =
|
type scoreArgs =
|
||||||
| DistEstimateDistAnswer(abstractScoreArgs<pointSetDist, pointSetDist>)
|
| DistEstimateDistAnswer(abstractScoreArgs<pointSetDist, pointSetDist>)
|
||||||
| DistEstimateScalarAnswer(abstractScoreArgs<pointSetDist, scalar>)
|
| DistEstimateScalarAnswer(abstractScoreArgs<pointSetDist, scalar>)
|
||||||
| ScalarEstimateScalarAnswer(abstractScoreArgs<scalar, 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> => {
|
||||||
|
@ -130,23 +129,6 @@ module WithScalarAnswer = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module TwoScalars = {
|
|
||||||
// You will almost never want to use this.
|
|
||||||
let score = (~estimate: scalar, ~answer: scalar) => {
|
|
||||||
if Js.Math.abs_float(estimate -. answer) < MagicNumbers.Epsilon.ten {
|
|
||||||
0.0->Ok
|
|
||||||
} else {
|
|
||||||
infinity->Ok // - log(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let scoreWithPrior = (~estimate: scalar, ~answer: scalar, ~prior: scalar) => {
|
|
||||||
E.R.merge(score(~estimate, ~answer), score(~estimate=prior, ~answer))->E.R2.fmap(((s1, s2)) =>
|
|
||||||
s1 -. s2
|
|
||||||
) // This will presently NaN if both are wrong: infinity-infinity.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let twoGenericDistsToTwoPointSetDists = (~toPointSetFn, estimate, answer): result<
|
let twoGenericDistsToTwoPointSetDists = (~toPointSetFn, estimate, answer): result<
|
||||||
(pointSetDist, pointSetDist),
|
(pointSetDist, pointSetDist),
|
||||||
'e,
|
'e,
|
||||||
|
@ -165,8 +147,4 @@ let logScore = (args: scoreArgs, ~combineFn, ~integrateFn, ~toMixedFn): result<
|
||||||
WithScalarAnswer.score(~estimate, ~answer)
|
WithScalarAnswer.score(~estimate, ~answer)
|
||||||
| DistEstimateScalarAnswer({estimate, answer, prior: Some(prior)}) =>
|
| DistEstimateScalarAnswer({estimate, answer, prior: Some(prior)}) =>
|
||||||
WithScalarAnswer.scoreWithPrior(~estimate, ~answer, ~prior)
|
WithScalarAnswer.scoreWithPrior(~estimate, ~answer, ~prior)
|
||||||
| ScalarEstimateScalarAnswer({estimate, answer, prior: None}) =>
|
|
||||||
TwoScalars.score(~estimate, ~answer)
|
|
||||||
| ScalarEstimateScalarAnswer({estimate, answer, prior: Some(prior)}) =>
|
|
||||||
TwoScalars.scoreWithPrior(~estimate, ~answer, ~prior)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user