From 69d962ce753dfdef944d834cc7fa99b81a82053f Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Wed, 18 May 2022 19:10:34 -0400 Subject: [PATCH] Wip, working on allowing distributions in normal --- .../squiggle-lang/src/rescript/FunctionRegistry.res | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry.res b/packages/squiggle-lang/src/rescript/FunctionRegistry.res index d01d5736..7a74ed0c 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry.res @@ -258,12 +258,24 @@ let p5and95 = (p5, p95) => contain(SymbolicDist.Normal.from90PercentCI(p5, p95)) let convertTwoInputs = (inputs: array): result => twoNumberInputs(inputs)->E.R.bind(((mean, stdev)) => meanStdev(mean, stdev)) +// let twoDistOrStdev = (a1:distOrNumber, a2:distOrNumber, fn) => { +// switch (a1, a2) { +// | (Number(a1), Number(a2)) => fn(a1, a2) +// | (Dist(a1), Number(a2)) => toSampleSetDist(a1, 1000)->sampleMap(r => fn(r, a2) |> sample) +// | (Number(a1), Dist(a2)) => toSampleSetDist(a2, 1000)->sampleMap(r => fn(a1, r) |> sample) +// | (Dist(a1), Dist(a2)) => SampleSetDist.map2(a1, a2, (m, s) => fn(m, s) |> sample) +// } +// } + let normal = Function.make( "Normal", [ Function.makeDefinition("normal", [I_Numeric, I_Numeric], inputs => twoNumberInputs(inputs)->E.R.bind(((mean, stdev)) => meanStdev(mean, stdev)) ), + Function.makeDefinition("normal", [I_DistOrNumber, I_DistOrNumber], inputs => + twoNumberInputs(inputs)->E.R.bind(((mean, stdev)) => meanStdev(mean, stdev)) + ), Function.makeDefinition( "normal", [I_Record([("mean", I_Numeric), ("stdev", I_Numeric)])],