cleanup; CR

Value: [1e-9 to 1e-5]
This commit is contained in:
Quinn Dougherty 2022-05-04 18:19:47 -04:00
parent 6211d3cfb0
commit dd942fe29e
4 changed files with 2 additions and 33 deletions

View File

@ -9,7 +9,7 @@ describe("dotSubtract", () => {
test("mean of normal minus exponential (unit)", () => { test("mean of normal minus exponential (unit)", () => {
let mean = 0.0 let mean = 0.0
let rate = 10.0 let rate = 10.0
exception MeanFailed
let dotDifference = DistributionOperation.Constructors.pointwiseSubtract( let dotDifference = DistributionOperation.Constructors.pointwiseSubtract(
~env, ~env,
mkNormal(mean, 1.0), mkNormal(mean, 1.0),
@ -19,7 +19,7 @@ describe("dotSubtract", () => {
let meanAnalytical = mean -. 1.0 /. rate let meanAnalytical = mean -. 1.0 /. rate
switch meanResult { switch meanResult {
| Ok(meanValue) => meanValue->expect->toBeCloseTo(meanAnalytical) | Ok(meanValue) => meanValue->expect->toBeCloseTo(meanAnalytical)
| Error(err) => err->expect->toBe(DistributionTypes.OperationError(DivisionByZeroError)) | Error(_) => raise(MeanFailed)
} }
}) })
Skip.test("mean of normal minus exponential (property)", () => { Skip.test("mean of normal minus exponential (property)", () => {

View File

@ -1,11 +0,0 @@
/*
This test case comes via Nuño https://github.com/quantified-uncertainty/squiggle/issues/433
*/
open Jest
open Expect
describe("KL divergence", () => {
test("our's agrees with analytical", () => {
true->expect->toBe(true)
})
})

View File

@ -1,19 +0,0 @@
import { testRun } from "./TestHelpers";
describe("KL divergence", () => {
test.skip("by integral solver agrees with analytical", () => {
let squiggleStringKL = `prediction=normal(4, 1)
answer=normal(1,1)
logSubtraction=dotSubtract(scaleLog(answer),scaleLog(prediction))
klintegrand=dotMultiply(logSubtraction, answer)
klintegral = integralSum(klintegrand)
analyticalKl = log(1 / 1) + 1 ^ 2 / (2 * 1 ^ 2) + ((4 - 1) * (1 - 4) / (2 * 1 * 1)) - 1 / 2
klintegral - analyticalKl`;
let squiggleResultKL = testRun(squiggleStringKL);
expect(squiggleResultKL.value).toBeCloseTo(0);
});
});
let squiggleStringLS = `prediction=normal(4,1)
answer=normal(1,1)
logScore(prediction, answer)`;

View File

@ -70,4 +70,3 @@ let cauchyMakeR = (local, rate) => fmapGenDist(SymbolicDist.Cauchy.make(local, r
let lognormalMakeR = (mu, sigma) => fmapGenDist(SymbolicDist.Lognormal.make(mu, sigma)) let lognormalMakeR = (mu, sigma) => fmapGenDist(SymbolicDist.Lognormal.make(mu, sigma))
let triangularMakeR = (low, mode, high) => let triangularMakeR = (low, mode, high) =>
fmapGenDist(SymbolicDist.Triangular.make(low, mode, high)) fmapGenDist(SymbolicDist.Triangular.make(low, mode, high))
// let floatMakeR = x =>E.R.fmap(s => DistributionTypes.Symbolic(s), SymbolicDist.Float.make(x))