Call Jstat for mean instead of calculate it
Value: [1e-8 to 1e-4]
This commit is contained in:
parent
dd942fe29e
commit
32a881d06a
|
@ -16,12 +16,20 @@ describe("dotSubtract", () => {
|
||||||
mkExponential(rate),
|
mkExponential(rate),
|
||||||
)
|
)
|
||||||
let meanResult = E.R2.bind(DistributionOperation.Constructors.mean(~env), dotDifference)
|
let meanResult = E.R2.bind(DistributionOperation.Constructors.mean(~env), dotDifference)
|
||||||
let meanAnalytical = mean -. 1.0 /. rate
|
let meanAnalytical =
|
||||||
|
mean -.
|
||||||
|
SymbolicDist.Exponential.mean({rate: rate})->E.R2.toExn(
|
||||||
|
"On trusted input this should never happen",
|
||||||
|
)
|
||||||
switch meanResult {
|
switch meanResult {
|
||||||
| Ok(meanValue) => meanValue->expect->toBeCloseTo(meanAnalytical)
|
| Ok(meanValue) => meanValue->expect->toBeCloseTo(meanAnalytical)
|
||||||
| Error(_) => raise(MeanFailed)
|
| Error(_) => raise(MeanFailed)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
/*
|
||||||
|
It seems like this test should work, and it's plausible that
|
||||||
|
there's some bug in `pointwiseSubtract`
|
||||||
|
*/
|
||||||
Skip.test("mean of normal minus exponential (property)", () => {
|
Skip.test("mean of normal minus exponential (property)", () => {
|
||||||
assert_(
|
assert_(
|
||||||
property2(float_(), floatRange(1e-5, 1e5), (mean, rate) => {
|
property2(float_(), floatRange(1e-5, 1e5), (mean, rate) => {
|
||||||
|
@ -33,11 +41,10 @@ describe("dotSubtract", () => {
|
||||||
)
|
)
|
||||||
let meanResult = E.R2.bind(DistributionOperation.Constructors.mean(~env), dotDifference)
|
let meanResult = E.R2.bind(DistributionOperation.Constructors.mean(~env), dotDifference)
|
||||||
// according to algebra or random variables,
|
// according to algebra or random variables,
|
||||||
let meanAnalytical = mean -. 1.0 /. rate
|
let meanAnalytical =
|
||||||
Js.Console.log3(
|
mean -.
|
||||||
mean,
|
SymbolicDist.Exponential.mean({rate: rate})->E.R2.toExn(
|
||||||
rate,
|
"On trusted input this should never happen",
|
||||||
E.R.fmap(x => abs_float(x -. meanAnalytical) /. abs_float(meanAnalytical), meanResult),
|
|
||||||
)
|
)
|
||||||
switch meanResult {
|
switch meanResult {
|
||||||
| Ok(meanValue) => abs_float(meanValue -. meanAnalytical) /. abs_float(meanValue) < 1e-2 // 1% relative error
|
| Ok(meanValue) => abs_float(meanValue -. meanAnalytical) /. abs_float(meanValue) < 1e-2 // 1% relative error
|
||||||
|
|
Loading…
Reference in New Issue
Block a user