diff --git a/packages/squiggle-lang/__tests__/DistTypes__Test.res b/packages/squiggle-lang/__tests__/DistTypes__Test.res index 5090ddd3..fb09d6d9 100644 --- a/packages/squiggle-lang/__tests__/DistTypes__Test.res +++ b/packages/squiggle-lang/__tests__/DistTypes__Test.res @@ -6,12 +6,12 @@ let makeTest = (~only=false, str, item1, item2) => ? Only.test(str, () => expect(item1) -> toEqual(item2)) : test(str, () => expect(item1) -> toEqual(item2)) -describe("DistTypes", () => +describe("PointSetTypes", () => describe("Domain", () => { let makeComplete = (yPoint, expectation) => makeTest( "With input: " ++ Js.Float.toString(yPoint), - DistTypes.Domain.yPointToSubYPoint(Complete, yPoint), + PointSetTypes.Domain.yPointToSubYPoint(Complete, yPoint), expectation, ) let makeSingle = (direction: [#left | #right], excludingProbabilityMass, yPoint, expectation) => @@ -19,7 +19,7 @@ describe("DistTypes", () => "Excluding: " ++ (Js.Float.toString(excludingProbabilityMass) ++ (" and yPoint: " ++ Js.Float.toString(yPoint))), - DistTypes.Domain.yPointToSubYPoint( + PointSetTypes.Domain.yPointToSubYPoint( direction == #left ? LeftLimited({xPoint: 3.0, excludingProbabilityMass: excludingProbabilityMass}) : RightLimited({xPoint: 3.0, excludingProbabilityMass: excludingProbabilityMass}), @@ -28,7 +28,7 @@ describe("DistTypes", () => expectation, ) let makeDouble = (domain, yPoint, expectation) => - makeTest("Excluding: limits", DistTypes.Domain.yPointToSubYPoint(domain, yPoint), expectation) + makeTest("Excluding: limits", PointSetTypes.Domain.yPointToSubYPoint(domain, yPoint), expectation) describe("With Complete Domain", () => { makeComplete(0.0, Some(0.0)) diff --git a/packages/squiggle-lang/__tests__/Distributions__Test.res b/packages/squiggle-lang/__tests__/Distributions__Test.res index 7b26962c..c28689b9 100644 --- a/packages/squiggle-lang/__tests__/Distributions__Test.res +++ b/packages/squiggle-lang/__tests__/Distributions__Test.res @@ -1,7 +1,7 @@ open Jest open Expect -let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} +// let PointSetDist: PointSetTypes.xyPointSetDist = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // let makeTest = (~only=false, str, item1, item2) => // only @@ -21,15 +21,15 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // expect(item1) |> toBeSoCloseTo(item2, ~digits) // ); -// describe("Shape", () => { +// describe("PointSetDist", () => { // describe("Continuous", () => { // open Continuous; -// let continuous = make(`Linear, shape, None); +// let continuous = make(`Linear, PointSetDist, None); // makeTest("minX", T.minX(continuous), 1.0); // makeTest("maxX", T.maxX(continuous), 8.0); // makeTest( // "mapY", -// T.mapY(r => r *. 2.0, continuous) |> getShape |> (r => r.ys), +// T.mapY(r => r *. 2.0, continuous) |> getPointSetDist |> (r => r.ys), // [|16., 18.0, 4.0|], // ); // describe("xToY", () => { @@ -57,7 +57,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // ); // }); // describe("when Stepwise", () => { -// let continuous = make(`Stepwise, shape, None); +// let continuous = make(`Stepwise, PointSetDist, None); // makeTest( // "at 4.0", // T.xToY(4., continuous), @@ -82,7 +82,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // }); // makeTest( // "integral", -// T.Integral.get(~cache=None, continuous) |> getShape, +// T.Integral.get(~cache=None, continuous) |> getPointSetDist, // {xs: [|1.0, 4.0, 8.0|], ys: [|0.0, 25.5, 47.5|]}, // ); // makeTest( @@ -90,7 +90,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // { // let continuous = // make(`Stepwise, {xs: [|1., 4., 8.|], ys: [|0.1, 5., 1.0|]}, None); -// continuous |> toLinear |> E.O.fmap(getShape); +// continuous |> toLinear |> E.O.fmap(getPointSetDist); // }, // Some({ // xs: [|1.00007, 1.00007, 4.0, 4.00007, 8.0, 8.00007|], @@ -101,7 +101,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // "toLinear", // { // let continuous = make(`Stepwise, {xs: [|0.0|], ys: [|0.3|]}, None); -// continuous |> toLinear |> E.O.fmap(getShape); +// continuous |> toLinear |> E.O.fmap(getPointSetDist); // }, // Some({xs: [|0.0|], ys: [|0.3|]}), // ); @@ -131,16 +131,16 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // describe("Discrete", () => { // open Discrete; -// let shape: DistTypes.xyShape = { +// let PointSetDist: PointSetTypes.xyPointSetDist = { // xs: [|1., 4., 8.|], // ys: [|0.3, 0.5, 0.2|], // }; -// let discrete = make(shape, None); +// let discrete = make(PointSetDist, None); // makeTest("minX", T.minX(discrete), 1.0); // makeTest("maxX", T.maxX(discrete), 8.0); // makeTest( // "mapY", -// T.mapY(r => r *. 2.0, discrete) |> (r => getShape(r).ys), +// T.mapY(r => r *. 2.0, discrete) |> (r => getPointSetDist(r).ys), // [|0.6, 1.0, 0.4|], // ); // makeTest( @@ -209,11 +209,11 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // describe("Mixed", () => { // open Distributions.Mixed; -// let discreteShape: DistTypes.xyShape = { +// let discretePointSetDist: PointSetTypes.xyPointSetDist = { // xs: [|1., 4., 8.|], // ys: [|0.3, 0.5, 0.2|], // }; -// let discrete = Discrete.make(discreteShape, None); +// let discrete = Discrete.make(discretePointSetDist, None); // let continuous = // Continuous.make( // `Linear, @@ -309,11 +309,11 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // describe("Distplus", () => { // open DistPlus; -// let discreteShape: DistTypes.xyShape = { +// let discretePointSetDist: PointSetTypes.xyPointSetDist = { // xs: [|1., 4., 8.|], // ys: [|0.3, 0.5, 0.2|], // }; -// let discrete = Discrete.make(discreteShape, None); +// let discrete = Discrete.make(discretePointSetDist, None); // let continuous = // Continuous.make( // `Linear, @@ -328,7 +328,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // ); // let distPlus = // DistPlus.make( -// ~shape=Mixed(mixed), +// ~PointSetDist=Mixed(mixed), // ~squiggleString=None, // (), // ); @@ -376,38 +376,38 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // ); // }); -// describe("Shape", () => { +// describe("PointSetDist", () => { // let mean = 10.0; // let stdev = 4.0; // let variance = stdev ** 2.0; // let numSamples = 10000; -// open Distributions.Shape; -// let normal: SymbolicTypes.symbolicDist = `Normal({mean, stdev}); -// let normalShape = ExpressionTree.toShape(numSamples, `SymbolicDist(normal)); +// open Distributions.PointSetDist; +// let normal: SymbolicDistTypes.symbolicDist = `Normal({mean, stdev}); +// let normalPointSetDist = AST.toPointSetDist(numSamples, `SymbolicDist(normal)); // let lognormal = SymbolicDist.Lognormal.fromMeanAndStdev(mean, stdev); -// let lognormalShape = ExpressionTree.toShape(numSamples, `SymbolicDist(lognormal)); +// let lognormalPointSetDist = AST.toPointSetDist(numSamples, `SymbolicDist(lognormal)); // makeTestCloseEquality( // "Mean of a normal", -// T.mean(normalShape), +// T.mean(normalPointSetDist), // mean, // ~digits=2, // ); // makeTestCloseEquality( // "Variance of a normal", -// T.variance(normalShape), +// T.variance(normalPointSetDist), // variance, // ~digits=1, // ); // makeTestCloseEquality( // "Mean of a lognormal", -// T.mean(lognormalShape), +// T.mean(lognormalPointSetDist), // mean, // ~digits=2, // ); // makeTestCloseEquality( // "Variance of a lognormal", -// T.variance(lognormalShape), +// T.variance(lognormalPointSetDist), // variance, // ~digits=0, // ); diff --git a/packages/squiggle-lang/__tests__/Hardcoded__Test.res b/packages/squiggle-lang/__tests__/Hardcoded__Test.res index 482019bc..bad6a5e3 100644 --- a/packages/squiggle-lang/__tests__/Hardcoded__Test.res +++ b/packages/squiggle-lang/__tests__/Hardcoded__Test.res @@ -10,12 +10,12 @@ let makeTest = (~only=false, str, item1, item2) => expect(item1) |> toEqual(item2) ); -let evalParams: ExpressionTypes.ExpressionTree.evaluationParams = { +let evalParams: ASTTypes.AST.evaluationParams = { samplingInputs: { sampleCount: 1000, outputXYPoints: 10000, kernelWidth: None, - shapeLength: 1000, + PointSetDistLength: 1000, }, environment: [| @@ -25,12 +25,12 @@ let evalParams: ExpressionTypes.ExpressionTree.evaluationParams = { ("T", `SymbolicDist(`Float(1000000000000.0))), |] ->Belt.Map.String.fromArray, - evaluateNode: ExpressionTreeEvaluator.toLeaf, + evaluateNode: ASTEvaluator.toLeaf, }; -let shape1: DistTypes.xyShape = {xs: [|1., 4., 8.|], ys: [|0.2, 0.4, 0.8|]}; +let PointSetDist1: PointSetTypes.xyPointSetDist = {xs: [|1., 4., 8.|], ys: [|0.2, 0.4, 0.8|]}; -describe("XYShapes", () => { +describe("XYPointSetDists", () => { describe("logScorePoint", () => { makeTest( "When identical", diff --git a/packages/squiggle-lang/__tests__/Samples__test.res b/packages/squiggle-lang/__tests__/Samples__test.res index c41fce23..9f908ee1 100644 --- a/packages/squiggle-lang/__tests__/Samples__test.res +++ b/packages/squiggle-lang/__tests__/Samples__test.res @@ -10,12 +10,12 @@ describe("Lodash", () => describe("Lodash", () => { makeTest( "split", - SamplesToShape.Internals.T.splitContinuousAndDiscrete([1.432, 1.33455, 2.0]), + SampleSet.Internals.T.splitContinuousAndDiscrete([1.432, 1.33455, 2.0]), ([1.432, 1.33455, 2.0], E.FloatFloatMap.empty()), ) makeTest( "split", - SamplesToShape.Internals.T.splitContinuousAndDiscrete([ + SampleSet.Internals.T.splitContinuousAndDiscrete([ 1.432, 1.33455, 2.0, @@ -32,13 +32,13 @@ describe("Lodash", () => E.A.concatMany([sorted, sorted, sorted, sorted]) |> Belt.SortArray.stableSortBy(_, compare) } - let (_, discrete) = SamplesToShape.Internals.T.splitContinuousAndDiscrete( + let (_, discrete) = SampleSet.Internals.T.splitContinuousAndDiscrete( makeDuplicatedArray(10), ) let toArr = discrete |> E.FloatFloatMap.toArray makeTest("splitMedium", toArr |> Belt.Array.length, 10) - let (c, discrete) = SamplesToShape.Internals.T.splitContinuousAndDiscrete( + let (c, discrete) = SampleSet.Internals.T.splitContinuousAndDiscrete( makeDuplicatedArray(500), ) let toArr = discrete |> E.FloatFloatMap.toArray diff --git a/packages/squiggle-lang/__tests__/XYShape__Test.res b/packages/squiggle-lang/__tests__/XYShape__Test.res index 10ee1c20..b4a693b5 100644 --- a/packages/squiggle-lang/__tests__/XYShape__Test.res +++ b/packages/squiggle-lang/__tests__/XYShape__Test.res @@ -6,25 +6,25 @@ let makeTest = (~only=false, str, item1, item2) => ? Only.test(str, () => expect(item1) -> toEqual(item2)) : test(str, () => expect(item1) -> toEqual(item2)) -let shape1: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [0.2, 0.4, 0.8]} +let pointSetDist1: PointSetTypes.xyShape = {xs: [1., 4., 8.], ys: [0.2, 0.4, 0.8]} -let shape2: DistTypes.xyShape = { +let pointSetDist2: PointSetTypes.xyShape = { xs: [1., 5., 10.], ys: [0.2, 0.5, 0.8], } -let shape3: DistTypes.xyShape = { +let pointSetDist3: PointSetTypes.xyShape = { xs: [1., 20., 50.], ys: [0.2, 0.5, 0.8], } describe("XYShapes", () => { describe("logScorePoint", () => { - makeTest("When identical", XYShape.logScorePoint(30, shape1, shape1), Some(0.0)) - makeTest("When similar", XYShape.logScorePoint(30, shape1, shape2), Some(1.658971191043856)) + makeTest("When identical", XYShape.logScorePoint(30, pointSetDist1, pointSetDist1), Some(0.0)) + makeTest("When similar", XYShape.logScorePoint(30, pointSetDist1, pointSetDist2), Some(1.658971191043856)) makeTest( "When very different", - XYShape.logScorePoint(30, shape1, shape3), + XYShape.logScorePoint(30, pointSetDist1, pointSetDist3), Some(210.3721280423322), ) }) @@ -41,7 +41,7 @@ describe("XYShapes", () => { describe("integrateWithTriangles", () => makeTest( "integrates correctly", - XYShape.Range.integrateWithTriangles(shape1), + XYShape.Range.integrateWithTriangles(pointSetDist1), Some({ xs: [1., 4., 8.], ys: [0.0, 0.9000000000000001, 3.3000000000000007], diff --git a/packages/squiggle-lang/dist/index.js b/packages/squiggle-lang/dist/index.js index 1297d6f0..7266c515 100644 --- a/packages/squiggle-lang/dist/index.js +++ b/packages/squiggle-lang/dist/index.js @@ -109,16 +109,16 @@ var e=arguments[3],r=function(){if("undefined"!=typeof globalThis)return globalT },{"rescript/lib/js/curry.js":"NSLD"}],"YXLi":[function(require,module,exports) { "use strict";var e=require("rescript/lib/js/curry.js"),t=require("rescript/lib/js/belt_Array.js"),r=require("rescript/lib/js/caml_array.js"),n=require("rescript/lib/js/pervasives.js"),s=require("../utility/E.bs.js"),a=require("./XYShape.bs.js"),i=require("../expressionTree/Operation.bs.js");function o(e,n){var i=void 0!==e&&e,o=a.T.length(n),g=n.ys,u=n.xs;u.unshift(r.get(u,0)),g.unshift(r.get(g,0)),u.push(r.get(u,o-1|0)),g.push(r.get(g,o-1|0));for(var f=s.A.length(u),c=new Array(f),h=new Array(f-1|0),l=new Array(f-2|0),p=0;pv&&(v=T)}for(var D=e._3(s.A.Floats.range,p,v,300),k=t.make(300,0),C=0,E=s.A.length(y);C0&&r.get(y,C)>0)for(var F=0,B=s.A.length(D);F=u&&e<=p},a.T.zip(o.xyShape)),s=r.O.dimap(function(e){return[[e-t.epsilon_float,0]]},function(e){return[]},e),h=r.O.dimap(function(e){return[[e+t.epsilon_float,0]]},function(e){return[]},i),m=n._1(r.A.concatMany,[s,c,h]);return l(void 0,void 0,void 0,a.T.fromZippedArray(m))}function P(e){var t=a.T.isEmpty(e.xyShape),i=e.integralCache;return t?y:void 0!==i?i:l(void 0,void 0,void 0,n._2(r.O.toExt,"This should not have happened",a.$$Range.integrateWithTriangles(e.xyShape)))}function E(e,n){var t=P(n).xyShape;return h(function(n){return a.XsConversion.proportionByProbabilityMass(e,t,n)},n)}function F(e){var t=P(e);return n._2(r.O.$$default,a.T.lastY(t.xyShape),e.integralSumCache)}function B(e,n){var t=P(n);return a.XtoY.linear(e,t.xyShape)}function R(e,n){var t=P(n);return a.YtoX.linear(e,t.xyShape)}function Z(e){return i.some(e)}function k(e){}function z(e){return Y(1,L(1/F(e),X(P(e),e)))}function U(e){return a.Analysis.integrateContinuousShape(function(e,n){return n*Math.pow(e,2)/2},function(e,n,t){return n*Math.pow(e,2)/2+t*Math.pow(e,3)/3},e)}function W(e){return a.Analysis.getVarianceDangerously(e,U,a.Analysis.getMeanOfSquaresContinuousShape)}var G=u.Dist({minX:D,maxX:M,mapY:j,xToY:q,toShape:A,toContinuous:Z,toDiscrete:k,normalize:z,toDiscreteProbabilityMassFraction:w,downsample:E,truncate:I,updateIntegralCache:X,integral:P,integralEndY:F,integralXtoY:B,integralYtoX:R,mean:U,variance:W});function V(e,n,t){var r=n.xyShape,o=t.xyShape;if(a.T.isEmpty(r)||a.T.isEmpty(o))return C;var c="Linear"===n.interpolation?n:b(n),s=p.combineShapesContinuousDiscrete(e,c.xyShape,o),h="Multiply"===e||"Divide"===e?u.Common.combineIntegralSums(function(e,n){return e*n},n.integralSumCache,t.integralSumCache):void 0;return l(n.interpolation,i.some(h),void 0,s)}function H(e,n,t){var r=n.xyShape,o=t.xyShape,c=a.T.length(r),s=a.T.length(o);if(0===c||0===s)return C;var h=p.combineShapesContinuousContinuous(e,r,o),m=u.Common.combineIntegralSums(function(e,n){return e*n},n.integralSumCache,t.integralSumCache);return l(void 0,i.some(m),void 0,h)}exports.getShape=c,exports.interpolation=s,exports.make=l,exports.shapeMap=h,exports.lastY=m,exports.oShapeMap=f,exports.emptyIntegral=y,exports.empty=C,exports.stepwiseToLinear=b,exports.combinePointwise=_,exports.toLinear=T,exports.shapeFn=O,exports.updateIntegralSumCache=Y,exports.updateIntegralCache=X,exports.reduce=$,exports.mapY=j,exports.scaleBy=L,exports.T=G,exports.combineAlgebraicallyWithDiscrete=V,exports.combineAlgebraically=H; -},{"rescript/lib/js/curry.js":"NSLD","rescript/lib/js/pervasives.js":"z22f","rescript/lib/js/caml_option.js":"dzFO","../utility/E.bs.js":"xX5m","./XYShape.bs.js":"Lf2V","./DistTypes.bs.js":"r7Vb","./Distributions.bs.js":"eTMD","./AlgebraicShapeCombination.bs.js":"YXLi"}],"Ms6F":[function(require,module,exports) { -"use strict";function e(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var r=require("rescript/lib/js/curry.js"),t=require("rescript/lib/js/belt_Array.js"),n=require("rescript/lib/js/caml_array.js"),i=require("rescript/lib/js/pervasives.js"),a=require("rescript/lib/js/caml_option.js"),o=require("rescript/lib/js/belt_MutableMap.js"),u=require("../utility/E.bs.js"),c=require("./XYShape.bs.js"),s=require("./DistTypes.bs.js"),p=require("../expressionTree/Operation.bs.js"),l=require("./Continuous.bs.js"),f=require("./Distributions.bs.js");function h(e,r,t){return{xyShape:t,integralSumCache:void 0!==e?a.valFromOption(e):void 0,integralCache:void 0!==r?a.valFromOption(r):void 0}}function m(e,t){return{xyShape:r._1(e,t.xyShape),integralSumCache:t.integralSumCache,integralCache:t.integralCache}}function y(e){return e.xyShape}function g(e,t){var n=a.some(t.integralCache),i=a.some(t.integralSumCache);return r._2(u.O.fmap,function(e){return h(i,n,e)},r._1(e,t.xyShape))}var S={xs:[i.neg_infinity],ys:[0]},x=0,d={xyShape:S,interpolation:"Stepwise",integralSumCache:x,integralCache:void 0},v=c.T.empty,C=0,b=d,_={xyShape:v,integralSumCache:C,integralCache:b};function T(e,t){return r._1(e,t.xyShape)}function j(e){return c.T.lastY(e.xyShape)}function Y(e,r,t,n,i){var o=void 0!==e?e:function(e,r){},u=f.Common.combineIntegralSums(o,n.integralSumCache,i.integralSumCache);return h(a.some(u),void 0,c.PointwiseCombination.combine(function(e,r){return e+r},c.XtoY.discreteInterpolator,n.xyShape,i.xyShape))}function X(e,t,n,i){var a=void 0!==t?t:function(e,r){},o=void 0!==e?e:function(e,r){};return r._3(u.A.fold_left,function(e,r){return Y(o,a,n,e,r)},_,i)}function O(e,r){return{xyShape:r.xyShape,integralSumCache:e,integralCache:r.integralCache}}function q(e,r){return{xyShape:r.xyShape,integralSumCache:r.integralSumCache,integralCache:e}}function A(e,t,i){for(var s=t.xyShape,l=i.xyShape,m=c.T.length(s),y=c.T.length(l),g=f.Common.combineIntegralSums(function(e,r){return e*r},t.integralSumCache,i.integralSumCache),S=p.Algebraic.toFn(e),x=u.FloatFloatMap.empty(void 0),d=0;d=1&&n>1?h(void 0,void 0,c.T.fromZippedArray(c.Zipped.sortByX(t.slice(t.reverse(c.Zipped.sortByY(c.T.zip(r.xyShape))),0,e)))):r}function G(e,t,n){return h(void 0,void 0,c.T.fromZippedArray(c.Zipped.filterByX(function(n){return n>=r._2(u.O.$$default,i.neg_infinity,e)&&n<=r._2(u.O.$$default,i.infinity,t)},c.T.zip(n.xyShape))))}function V(e,t){return s.MixedPoint.makeDiscrete(r._2(u.O.$$default,0,c.XtoY.stepwiseIfAtX(e,t.xyShape)))}function H(e,r){return c.XtoY.linear(e,l.getShape(M(r)))}function J(e,r){return c.YtoX.linear(e,l.getShape(M(r)))}function K(e){var t=e.xyShape;return r._3(u.A.reducei,t.xs,0,function(e,r,i){return e+r*n.get(t.ys,i)})}function L(e){return c.Analysis.getVarianceDangerously(e,K,function(e){return K(m(c.Analysis.squareXYShape,e))})}var N=f.Dist({minX:I,maxX:w,mapY:F,xToY:V,toShape:B,toContinuous:P,toDiscrete:k,normalize:z,toDiscreteProbabilityMassFraction:Z,downsample:E,truncate:G,updateIntegralCache:q,integral:M,integralEndY:D,integralXtoY:H,integralYtoX:J,mean:K,variance:L});exports.make=h,exports.shapeMap=m,exports.getShape=y,exports.oShapeMap=g,exports.emptyIntegral=d,exports.empty=_,exports.shapeFn=T,exports.lastY=j,exports.combinePointwise=Y,exports.reduce=X,exports.updateIntegralSumCache=O,exports.updateIntegralCache=q,exports.combineAlgebraically=A,exports.mapY=F,exports.scaleBy=$,exports.T=N; -},{"rescript/lib/js/curry.js":"NSLD","rescript/lib/js/belt_Array.js":"yUxI","rescript/lib/js/caml_array.js":"Tpli","rescript/lib/js/pervasives.js":"z22f","rescript/lib/js/caml_option.js":"dzFO","rescript/lib/js/belt_MutableMap.js":"aHaK","../utility/E.bs.js":"xX5m","./XYShape.bs.js":"Lf2V","./DistTypes.bs.js":"r7Vb","../expressionTree/Operation.bs.js":"S4ET","./Continuous.bs.js":"CVcq","./Distributions.bs.js":"eTMD"}],"XMuZ":[function(require,module,exports) { -"use strict";function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var n=require("rescript/lib/js/caml.js"),t=require("rescript/lib/js/curry.js"),r=require("rescript/lib/js/caml_option.js"),i=require("../utility/E.bs.js"),a=require("./XYShape.bs.js"),o=require("./Discrete.bs.js"),u=require("./DistTypes.bs.js"),c=require("./Continuous.bs.js"),s=require("./Distributions.bs.js");function l(e,n,t,i){return{continuous:t,discrete:i,integralSumCache:void 0!==e?r.valFromOption(e):void 0,integralCache:void 0!==n?r.valFromOption(n):void 0}}function m(e){return a.T.length(c.getShape(e.continuous))+a.T.length(o.getShape(e.discrete))|0}function d(e,n){var a=void 0!==e?e:1,u=o.scaleBy(a,n.discrete),s=c.scaleBy(a,n.continuous),m=t._2(i.O.bind,n.integralCache,function(e){return c.scaleBy(a,e)}),d=t._2(i.O.bind,n.integralSumCache,function(e){return e*a});return l(r.some(d),r.some(m),s,u)}function g(e){return e.continuous}function h(e){return e.discrete}function p(e,n){return{continuous:n.continuous,discrete:n.discrete,integralSumCache:n.integralSumCache,integralCache:e}}function _(e){return n.caml_float_min(t._1(c.T.minX,e.continuous),t._1(o.T.minX,e.discrete))}function C(e){return n.caml_float_max(t._1(c.T.maxX,e.continuous),t._1(o.T.maxX,e.discrete))}function v(n){return e({TAG:0,_0:n},Symbol.for("name"),"Mixed")}function f(e,n,i){var a=t._3(c.T.truncate,e,n,i.continuous),u=t._3(o.T.truncate,e,n,i.discrete);return l(r.some(void 0),r.some(void 0),a,u)}function b(e){var n=t._1(c.T.Integral.get,e.continuous),i=t._1(o.T.Integral.get,e.discrete),a=c.updateIntegralCache(n,e.continuous),u=o.updateIntegralCache(i,e.discrete),s=t._1(c.T.Integral.sum,a),m=t._1(o.T.Integral.sum,u),d=s+m,g=s/d,h=m/d,p=c.updateIntegralSumCache(g,c.scaleBy(g/s,a)),_=o.updateIntegralSumCache(h,o.scaleBy(h/m,u));return l(1,r.some(void 0),p,_)}function T(e,n){var r=b(n),i=t._2(c.T.xToY,e,r.continuous),a=t._2(o.T.xToY,e,r.discrete);return u.MixedPoint.add(i,a)}function S(e){var n=t._1(o.T.Integral.sum,e.discrete);return n/(n+t._1(c.T.Integral.sum,e.continuous))}function I(e,n){var r=t._1(o.T.Integral.sum,n.discrete),i=t._1(c.T.Integral.sum,n.continuous),a=r+i,u=t._2(o.T.downsample,e*(r/a)|0,n.discrete);return{continuous:t._2(c.T.downsample,e*(i/a)|0,n.continuous),discrete:u,integralSumCache:n.integralSumCache,integralCache:n.integralCache}}function y(e){var n=e.integralCache;if(void 0!==n)return n;var r=t._1(c.T.Integral.get,e.continuous),i=c.stepwiseToLinear(t._1(o.T.Integral.get,e.discrete));return c.make(void 0,void 0,void 0,a.PointwiseCombination.combine(function(e,n){return e+n},a.XtoY.continuousInterpolator("Linear","UseOutermostPoints"),c.getShape(r),c.getShape(i)))}function x(e){return c.lastY(y(e))}function O(e,n){return a.XtoY.linear(e,c.getShape(y(n)))}function Y(e,n){return a.YtoX.linear(e,c.getShape(y(n)))}function j(e,n,r,a){var u=void 0!==e?e:function(e){},s=void 0!==n?n:function(e){},l=o.T.mapY,m=o.updateIntegralCache(t._2(i.O.bind,a.discrete.integralCache,s),o.updateIntegralSumCache(t._2(i.O.bind,a.discrete.integralSumCache,u),t._4(l,void 0,void 0,r,a.discrete))),d=c.T.mapY;return{continuous:c.updateIntegralCache(t._2(i.O.bind,a.continuous.integralCache,s),c.updateIntegralSumCache(t._2(i.O.bind,a.continuous.integralSumCache,u),t._4(d,void 0,void 0,r,a.continuous))),discrete:m,integralSumCache:t._2(i.O.bind,a.integralSumCache,u),integralCache:t._2(i.O.bind,a.integralCache,s)}}function A(e){var n=e.discrete,r=e.continuous,i=t._1(o.T.mean,n),a=t._1(c.T.mean,r),u=t._1(o.T.Integral.sum,n),s=t._1(c.T.Integral.sum,r);return(i*u+a*s)/(u+s)}function X(e){var n=e.discrete,r=e.continuous,i=t._1(o.T.Integral.sum,n),u=t._1(c.T.Integral.sum,r),s=i+u,l=i/s;return 0!==l?1!==l?a.Analysis.getVarianceDangerously(e,A,function(e){var n=t._1(o.T.mean,o.shapeMap(a.Analysis.squareXYShape,e.discrete)),r=a.Analysis.getMeanOfSquaresContinuousShape(e.continuous);return(n*i+r*u)/s}):t._1(o.T.variance,n):t._1(c.T.variance,r)}var q=s.Dist({minX:_,maxX:C,mapY:j,xToY:T,toShape:v,toContinuous:g,toDiscrete:h,normalize:b,toDiscreteProbabilityMassFraction:S,downsample:I,truncate:f,updateIntegralCache:p,integral:y,integralEndY:x,integralXtoY:O,integralYtoX:Y,mean:A,variance:X});function D(e,n,t){var r=c.combineAlgebraically(e,n.continuous,t.continuous),i=c.combineAlgebraicallyWithDiscrete(e,t.continuous,n.discrete),a=c.combineAlgebraicallyWithDiscrete(e,n.continuous,t.discrete);return{continuous:c.reduce(void 0,void 0,function(e,n){return e+n},[r,i,a]),discrete:o.combineAlgebraically(e,n.discrete,t.discrete),integralSumCache:s.Common.combineIntegralSums(function(e,n){return e*n},n.integralSumCache,t.integralSumCache),integralCache:void 0}}function w(e,n,a,u,m){var d=void 0!==e?e:function(e,n){},p=void 0!==n?n:function(e,n){},_=o.reduce(d,p,a,t._1(i.A.O.concatSomes,t._2(i.A.fmap,h,[u,m]))),C=c.reduce(d,p,a,t._1(i.A.O.concatSomes,t._2(i.A.fmap,g,[u,m]))),v=s.Common.combineIntegralSums(d,u.integralSumCache,m.integralSumCache),f=s.Common.combineIntegrals(p,u.integralCache,m.integralCache);return l(r.some(v),r.some(f),C,_)}exports.make=l,exports.totalLength=m,exports.scaleBy=d,exports.toContinuous=g,exports.toDiscrete=h,exports.updateIntegralCache=p,exports.T=q,exports.combineAlgebraically=D,exports.combinePointwise=w; -},{"rescript/lib/js/caml.js":"gGFE","rescript/lib/js/curry.js":"NSLD","rescript/lib/js/caml_option.js":"dzFO","../utility/E.bs.js":"xX5m","./XYShape.bs.js":"Lf2V","./Discrete.bs.js":"Ms6F","./DistTypes.bs.js":"r7Vb","./Continuous.bs.js":"CVcq","./Distributions.bs.js":"eTMD"}],"wbI6":[function(require,module,exports) { +"use strict";function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var n=require("rescript/lib/js/curry.js"),t=require("rescript/lib/js/pervasives.js"),i=require("rescript/lib/js/caml_option.js"),r=require("../utility/E.bs.js"),a=require("./XYShape.bs.js"),o=require("./PointSetTypes.bs.js"),u=require("./Distributions.bs.js"),p=require("./AlgebraicShapeCombination.bs.js");function c(e){return e.xyShape}function s(e){return e.interpolation}function l(e,n,t,r){return{xyShape:r,interpolation:void 0!==e?e:"Linear",integralSumCache:void 0!==n?i.valFromOption(n):void 0,integralCache:void 0!==t?i.valFromOption(t):void 0}}function h(e,t){return{xyShape:n._1(e,t.xyShape),interpolation:t.interpolation,integralSumCache:t.integralSumCache,integralCache:t.integralCache}}function m(e){return a.T.lastY(e.xyShape)}function f(e,t){var a=i.some(t.integralCache),o=i.some(t.integralSumCache),u=t.interpolation;return n._2(r.O.fmap,function(e){return l(u,o,a,e)},n._1(e,t.xyShape))}var S={xs:[t.neg_infinity],ys:[0]},g=0,y={xyShape:S,interpolation:"Linear",integralSumCache:g,integralCache:void 0},v=a.T.empty,x=0,d=y,C={xyShape:v,interpolation:"Linear",integralSumCache:x,integralCache:d};function b(e){return l(void 0,i.some(e.integralSumCache),i.some(e.integralCache),a.$$Range.stepwiseToLinear(e.xyShape))}function _(e,n,t,r,o,p){var c=void 0!==e?e:function(e,n){},s=void 0!==t?t:"PDF",h=u.Common.combineIntegralSums(c,o.integralSumCache,p.integralSumCache),m=o.interpolation,f=p.interpolation,S="Linear"===m?"Linear"===f?[o,p]:[o,b(p)]:"Linear"===f?[b(o),p]:[o,p],g=S[0],y="PDF"===s?"UseZero":"UseOutermostPoints",v=a.XtoY.continuousInterpolator(g.interpolation,y);return l(void 0,i.some(h),void 0,a.PointwiseCombination.combine(r,v,g.xyShape,S[1].xyShape))}function T(e){if("Linear"===e.interpolation)return e;var t=i.some(e.integralSumCache),o=i.some(e.integralCache);return n._2(r.O.fmap,function(e){return l(void 0,t,o,e)},a.$$Range.stepsToContinuous(e.xyShape))}function O(e,t){return n._1(e,t.xyShape)}function Y(e,n){return{xyShape:n.xyShape,interpolation:n.interpolation,integralSumCache:e,integralCache:n.integralCache}}function X(e,n){return{xyShape:n.xyShape,interpolation:n.interpolation,integralSumCache:n.integralSumCache,integralCache:e}}function $(e,t,i,a){var o=void 0!==t?t:function(e,n){},u=void 0!==e?e:function(e,n){};return n._3(r.A.fold_left,function(e,n){return _(u,o,void 0,i,e,n)},C,a)}function j(e,t,o,u){var p=void 0!==e?e:function(e){},c=void 0!==t?t:function(e){},s=u.integralSumCache,h=u.integralCache;return l(u.interpolation,i.some(n._2(r.O.bind,s,p)),i.some(n._2(r.O.bind,h,c)),a.T.mapY(o,u.xyShape))}function L(e,t){var i=void 0!==e?e:1,a=n._2(r.O.bind,t.integralSumCache,function(e){return i*e});return X(n._2(r.O.bind,t.integralCache,function(e){return L(i,e)}),Y(a,j(void 0,void 0,function(e){return e*i},t)))}function D(e){return a.T.minX(e.xyShape)}function M(e){return a.T.maxX(e.xyShape)}function w(e){return 0}function A(n){return e({TAG:2,_0:n},Symbol.for("name"),"Continuous")}function q(e,t){var i=t.xyShape;return o.MixedPoint.makeContinuous("Linear"===t.interpolation?a.XtoY.linear(e,i):n._2(r.O.$$default,0,a.XtoY.stepwiseIncremental(e,i)))}function I(e,i,o){var u=n._2(r.O.$$default,t.neg_infinity,e),p=n._2(r.O.$$default,t.infinity,i),c=a.Zipped.filterByX(function(e){return e>=u&&e<=p},a.T.zip(o.xyShape)),s=r.O.dimap(function(e){return[[e-t.epsilon_float,0]]},function(e){return[]},e),h=r.O.dimap(function(e){return[[e+t.epsilon_float,0]]},function(e){return[]},i),m=n._1(r.A.concatMany,[s,c,h]);return l(void 0,void 0,void 0,a.T.fromZippedArray(m))}function P(e){var t=a.T.isEmpty(e.xyShape),i=e.integralCache;return t?y:void 0!==i?i:l(void 0,void 0,void 0,n._2(r.O.toExt,"This should not have happened",a.$$Range.integrateWithTriangles(e.xyShape)))}function E(e,n){var t=P(n).xyShape;return h(function(n){return a.XsConversion.proportionByProbabilityMass(e,t,n)},n)}function F(e){var t=P(e);return n._2(r.O.$$default,a.T.lastY(t.xyShape),e.integralSumCache)}function B(e,n){var t=P(n);return a.XtoY.linear(e,t.xyShape)}function R(e,n){var t=P(n);return a.YtoX.linear(e,t.xyShape)}function Z(e){return i.some(e)}function k(e){}function z(e){return Y(1,L(1/F(e),X(P(e),e)))}function U(e){return a.Analysis.integrateContinuousShape(function(e,n){return n*Math.pow(e,2)/2},function(e,n,t){return n*Math.pow(e,2)/2+t*Math.pow(e,3)/3},e)}function W(e){return a.Analysis.getVarianceDangerously(e,U,a.Analysis.getMeanOfSquaresContinuousShape)}var G=u.Dist({minX:D,maxX:M,mapY:j,xToY:q,toShape:A,toContinuous:Z,toDiscrete:k,normalize:z,toDiscreteProbabilityMassFraction:w,downsample:E,truncate:I,updateIntegralCache:X,integral:P,integralEndY:F,integralXtoY:B,integralYtoX:R,mean:U,variance:W});function V(e,n,t){var r=n.xyShape,o=t.xyShape;if(a.T.isEmpty(r)||a.T.isEmpty(o))return C;var c="Linear"===n.interpolation?n:b(n),s=p.combineShapesContinuousDiscrete(e,c.xyShape,o),h="Multiply"===e||"Divide"===e?u.Common.combineIntegralSums(function(e,n){return e*n},n.integralSumCache,t.integralSumCache):void 0;return l(n.interpolation,i.some(h),void 0,s)}function H(e,n,t){var r=n.xyShape,o=t.xyShape,c=a.T.length(r),s=a.T.length(o);if(0===c||0===s)return C;var h=p.combineShapesContinuousContinuous(e,r,o),m=u.Common.combineIntegralSums(function(e,n){return e*n},n.integralSumCache,t.integralSumCache);return l(void 0,i.some(m),void 0,h)}exports.getShape=c,exports.interpolation=s,exports.make=l,exports.shapeMap=h,exports.lastY=m,exports.oShapeMap=f,exports.emptyIntegral=y,exports.empty=C,exports.stepwiseToLinear=b,exports.combinePointwise=_,exports.toLinear=T,exports.shapeFn=O,exports.updateIntegralSumCache=Y,exports.updateIntegralCache=X,exports.reduce=$,exports.mapY=j,exports.scaleBy=L,exports.T=G,exports.combineAlgebraicallyWithDiscrete=V,exports.combineAlgebraically=H; +},{"rescript/lib/js/curry.js":"NSLD","rescript/lib/js/pervasives.js":"z22f","rescript/lib/js/caml_option.js":"dzFO","../utility/E.bs.js":"xX5m","./XYShape.bs.js":"Lf2V","./PointSetTypes.bs.js":"r7Vb","./Distributions.bs.js":"eTMD","./AlgebraicShapeCombination.bs.js":"YXLi"}],"Ms6F":[function(require,module,exports) { +"use strict";function e(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var r=require("rescript/lib/js/curry.js"),t=require("rescript/lib/js/belt_Array.js"),n=require("rescript/lib/js/caml_array.js"),i=require("rescript/lib/js/pervasives.js"),a=require("rescript/lib/js/caml_option.js"),o=require("rescript/lib/js/belt_MutableMap.js"),u=require("../utility/E.bs.js"),c=require("./XYShape.bs.js"),s=require("./PointSetTypes.bs.js"),p=require("../expressionTree/Operation.bs.js"),l=require("./Continuous.bs.js"),f=require("./Distributions.bs.js");function h(e,r,t){return{xyShape:t,integralSumCache:void 0!==e?a.valFromOption(e):void 0,integralCache:void 0!==r?a.valFromOption(r):void 0}}function m(e,t){return{xyShape:r._1(e,t.xyShape),integralSumCache:t.integralSumCache,integralCache:t.integralCache}}function y(e){return e.xyShape}function g(e,t){var n=a.some(t.integralCache),i=a.some(t.integralSumCache);return r._2(u.O.fmap,function(e){return h(i,n,e)},r._1(e,t.xyShape))}var S={xs:[i.neg_infinity],ys:[0]},x=0,d={xyShape:S,interpolation:"Stepwise",integralSumCache:x,integralCache:void 0},v=c.T.empty,C=0,b=d,_={xyShape:v,integralSumCache:C,integralCache:b};function T(e,t){return r._1(e,t.xyShape)}function j(e){return c.T.lastY(e.xyShape)}function Y(e,r,t,n,i){var o=void 0!==e?e:function(e,r){},u=f.Common.combineIntegralSums(o,n.integralSumCache,i.integralSumCache);return h(a.some(u),void 0,c.PointwiseCombination.combine(function(e,r){return e+r},c.XtoY.discreteInterpolator,n.xyShape,i.xyShape))}function X(e,t,n,i){var a=void 0!==t?t:function(e,r){},o=void 0!==e?e:function(e,r){};return r._3(u.A.fold_left,function(e,r){return Y(o,a,n,e,r)},_,i)}function O(e,r){return{xyShape:r.xyShape,integralSumCache:e,integralCache:r.integralCache}}function q(e,r){return{xyShape:r.xyShape,integralSumCache:r.integralSumCache,integralCache:e}}function A(e,t,i){for(var s=t.xyShape,l=i.xyShape,m=c.T.length(s),y=c.T.length(l),g=f.Common.combineIntegralSums(function(e,r){return e*r},t.integralSumCache,i.integralSumCache),S=p.Algebraic.toFn(e),x=u.FloatFloatMap.empty(void 0),d=0;d=1&&n>1?h(void 0,void 0,c.T.fromZippedArray(c.Zipped.sortByX(t.slice(t.reverse(c.Zipped.sortByY(c.T.zip(r.xyShape))),0,e)))):r}function G(e,t,n){return h(void 0,void 0,c.T.fromZippedArray(c.Zipped.filterByX(function(n){return n>=r._2(u.O.$$default,i.neg_infinity,e)&&n<=r._2(u.O.$$default,i.infinity,t)},c.T.zip(n.xyShape))))}function V(e,t){return s.MixedPoint.makeDiscrete(r._2(u.O.$$default,0,c.XtoY.stepwiseIfAtX(e,t.xyShape)))}function H(e,r){return c.XtoY.linear(e,l.getShape(M(r)))}function J(e,r){return c.YtoX.linear(e,l.getShape(M(r)))}function K(e){var t=e.xyShape;return r._3(u.A.reducei,t.xs,0,function(e,r,i){return e+r*n.get(t.ys,i)})}function L(e){return c.Analysis.getVarianceDangerously(e,K,function(e){return K(m(c.Analysis.squareXYShape,e))})}var N=f.Dist({minX:I,maxX:w,mapY:F,xToY:V,toShape:B,toContinuous:P,toDiscrete:k,normalize:z,toDiscreteProbabilityMassFraction:Z,downsample:E,truncate:G,updateIntegralCache:q,integral:M,integralEndY:D,integralXtoY:H,integralYtoX:J,mean:K,variance:L});exports.make=h,exports.shapeMap=m,exports.getShape=y,exports.oShapeMap=g,exports.emptyIntegral=d,exports.empty=_,exports.shapeFn=T,exports.lastY=j,exports.combinePointwise=Y,exports.reduce=X,exports.updateIntegralSumCache=O,exports.updateIntegralCache=q,exports.combineAlgebraically=A,exports.mapY=F,exports.scaleBy=$,exports.T=N; +},{"rescript/lib/js/curry.js":"NSLD","rescript/lib/js/belt_Array.js":"yUxI","rescript/lib/js/caml_array.js":"Tpli","rescript/lib/js/pervasives.js":"z22f","rescript/lib/js/caml_option.js":"dzFO","rescript/lib/js/belt_MutableMap.js":"aHaK","../utility/E.bs.js":"xX5m","./XYShape.bs.js":"Lf2V","./PointSetTypes.bs.js":"r7Vb","../expressionTree/Operation.bs.js":"S4ET","./Continuous.bs.js":"CVcq","./Distributions.bs.js":"eTMD"}],"XMuZ":[function(require,module,exports) { +"use strict";function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var n=require("rescript/lib/js/caml.js"),t=require("rescript/lib/js/curry.js"),r=require("rescript/lib/js/caml_option.js"),i=require("../utility/E.bs.js"),a=require("./XYShape.bs.js"),o=require("./Discrete.bs.js"),u=require("./PointSetTypes.bs.js"),c=require("./Continuous.bs.js"),s=require("./Distributions.bs.js");function l(e,n,t,i){return{continuous:t,discrete:i,integralSumCache:void 0!==e?r.valFromOption(e):void 0,integralCache:void 0!==n?r.valFromOption(n):void 0}}function m(e){return a.T.length(c.getShape(e.continuous))+a.T.length(o.getShape(e.discrete))|0}function d(e,n){var a=void 0!==e?e:1,u=o.scaleBy(a,n.discrete),s=c.scaleBy(a,n.continuous),m=t._2(i.O.bind,n.integralCache,function(e){return c.scaleBy(a,e)}),d=t._2(i.O.bind,n.integralSumCache,function(e){return e*a});return l(r.some(d),r.some(m),s,u)}function g(e){return e.continuous}function h(e){return e.discrete}function p(e,n){return{continuous:n.continuous,discrete:n.discrete,integralSumCache:n.integralSumCache,integralCache:e}}function _(e){return n.caml_float_min(t._1(c.T.minX,e.continuous),t._1(o.T.minX,e.discrete))}function C(e){return n.caml_float_max(t._1(c.T.maxX,e.continuous),t._1(o.T.maxX,e.discrete))}function v(n){return e({TAG:0,_0:n},Symbol.for("name"),"Mixed")}function f(e,n,i){var a=t._3(c.T.truncate,e,n,i.continuous),u=t._3(o.T.truncate,e,n,i.discrete);return l(r.some(void 0),r.some(void 0),a,u)}function b(e){var n=t._1(c.T.Integral.get,e.continuous),i=t._1(o.T.Integral.get,e.discrete),a=c.updateIntegralCache(n,e.continuous),u=o.updateIntegralCache(i,e.discrete),s=t._1(c.T.Integral.sum,a),m=t._1(o.T.Integral.sum,u),d=s+m,g=s/d,h=m/d,p=c.updateIntegralSumCache(g,c.scaleBy(g/s,a)),_=o.updateIntegralSumCache(h,o.scaleBy(h/m,u));return l(1,r.some(void 0),p,_)}function T(e,n){var r=b(n),i=t._2(c.T.xToY,e,r.continuous),a=t._2(o.T.xToY,e,r.discrete);return u.MixedPoint.add(i,a)}function S(e){var n=t._1(o.T.Integral.sum,e.discrete);return n/(n+t._1(c.T.Integral.sum,e.continuous))}function I(e,n){var r=t._1(o.T.Integral.sum,n.discrete),i=t._1(c.T.Integral.sum,n.continuous),a=r+i,u=t._2(o.T.downsample,e*(r/a)|0,n.discrete);return{continuous:t._2(c.T.downsample,e*(i/a)|0,n.continuous),discrete:u,integralSumCache:n.integralSumCache,integralCache:n.integralCache}}function y(e){var n=e.integralCache;if(void 0!==n)return n;var r=t._1(c.T.Integral.get,e.continuous),i=c.stepwiseToLinear(t._1(o.T.Integral.get,e.discrete));return c.make(void 0,void 0,void 0,a.PointwiseCombination.combine(function(e,n){return e+n},a.XtoY.continuousInterpolator("Linear","UseOutermostPoints"),c.getShape(r),c.getShape(i)))}function x(e){return c.lastY(y(e))}function O(e,n){return a.XtoY.linear(e,c.getShape(y(n)))}function Y(e,n){return a.YtoX.linear(e,c.getShape(y(n)))}function j(e,n,r,a){var u=void 0!==e?e:function(e){},s=void 0!==n?n:function(e){},l=o.T.mapY,m=o.updateIntegralCache(t._2(i.O.bind,a.discrete.integralCache,s),o.updateIntegralSumCache(t._2(i.O.bind,a.discrete.integralSumCache,u),t._4(l,void 0,void 0,r,a.discrete))),d=c.T.mapY;return{continuous:c.updateIntegralCache(t._2(i.O.bind,a.continuous.integralCache,s),c.updateIntegralSumCache(t._2(i.O.bind,a.continuous.integralSumCache,u),t._4(d,void 0,void 0,r,a.continuous))),discrete:m,integralSumCache:t._2(i.O.bind,a.integralSumCache,u),integralCache:t._2(i.O.bind,a.integralCache,s)}}function A(e){var n=e.discrete,r=e.continuous,i=t._1(o.T.mean,n),a=t._1(c.T.mean,r),u=t._1(o.T.Integral.sum,n),s=t._1(c.T.Integral.sum,r);return(i*u+a*s)/(u+s)}function X(e){var n=e.discrete,r=e.continuous,i=t._1(o.T.Integral.sum,n),u=t._1(c.T.Integral.sum,r),s=i+u,l=i/s;return 0!==l?1!==l?a.Analysis.getVarianceDangerously(e,A,function(e){var n=t._1(o.T.mean,o.shapeMap(a.Analysis.squareXYShape,e.discrete)),r=a.Analysis.getMeanOfSquaresContinuousShape(e.continuous);return(n*i+r*u)/s}):t._1(o.T.variance,n):t._1(c.T.variance,r)}var q=s.Dist({minX:_,maxX:C,mapY:j,xToY:T,toShape:v,toContinuous:g,toDiscrete:h,normalize:b,toDiscreteProbabilityMassFraction:S,downsample:I,truncate:f,updateIntegralCache:p,integral:y,integralEndY:x,integralXtoY:O,integralYtoX:Y,mean:A,variance:X});function D(e,n,t){var r=c.combineAlgebraically(e,n.continuous,t.continuous),i=c.combineAlgebraicallyWithDiscrete(e,t.continuous,n.discrete),a=c.combineAlgebraicallyWithDiscrete(e,n.continuous,t.discrete);return{continuous:c.reduce(void 0,void 0,function(e,n){return e+n},[r,i,a]),discrete:o.combineAlgebraically(e,n.discrete,t.discrete),integralSumCache:s.Common.combineIntegralSums(function(e,n){return e*n},n.integralSumCache,t.integralSumCache),integralCache:void 0}}function w(e,n,a,u,m){var d=void 0!==e?e:function(e,n){},p=void 0!==n?n:function(e,n){},_=o.reduce(d,p,a,t._1(i.A.O.concatSomes,t._2(i.A.fmap,h,[u,m]))),C=c.reduce(d,p,a,t._1(i.A.O.concatSomes,t._2(i.A.fmap,g,[u,m]))),v=s.Common.combineIntegralSums(d,u.integralSumCache,m.integralSumCache),f=s.Common.combineIntegrals(p,u.integralCache,m.integralCache);return l(r.some(v),r.some(f),C,_)}exports.make=l,exports.totalLength=m,exports.scaleBy=d,exports.toContinuous=g,exports.toDiscrete=h,exports.updateIntegralCache=p,exports.T=q,exports.combineAlgebraically=D,exports.combinePointwise=w; +},{"rescript/lib/js/caml.js":"gGFE","rescript/lib/js/curry.js":"NSLD","rescript/lib/js/caml_option.js":"dzFO","../utility/E.bs.js":"xX5m","./XYShape.bs.js":"Lf2V","./Discrete.bs.js":"Ms6F","./PointSetTypes.bs.js":"r7Vb","./Continuous.bs.js":"CVcq","./Distributions.bs.js":"eTMD"}],"wbI6":[function(require,module,exports) { "use strict";function e(r){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(r)}function r(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var t=require("rescript/lib/js/curry.js"),n=require("rescript/lib/js/random.js"),a=require("rescript/lib/js/belt_Array.js"),o=require("rescript/lib/js/caml_option.js"),i=require("./Mixed.bs.js"),c=require("./Discrete.bs.js"),u=require("./Continuous.bs.js"),s=require("./Distributions.bs.js");function l(e,r){switch(0|r.TAG){case 0:return t._1(e[0],r._0);case 1:return t._1(e[1],r._0);case 2:return t._1(e[2],r._0)}}function T(e,n){switch(0|n.TAG){case 0:return r({TAG:0,_0:t._1(e[0],n._0)},Symbol.for("name"),"Mixed");case 1:return r({TAG:1,_0:t._1(e[1],n._0)},Symbol.for("name"),"Discrete");case 2:return r({TAG:2,_0:t._1(e[2],n._0)},Symbol.for("name"),"Continuous")}}function _(e){return e}function m(e){return i.make(o.some(e.integralSumCache),o.some(e.integralCache),u.empty,e)}function f(e){return i.make(o.some(e.integralSumCache),o.some(e.integralCache),e,c.empty)}var b=[_,m,f];function p(e){return l(b,e)}function g(e,r,n){switch(0|r.TAG){case 0:break;case 1:var a=r._0;switch(0|n.TAG){case 0:break;case 1:return t._1(c.T.toShape,c.combineAlgebraically(e,a,n._0));case 2:return t._1(u.T.toShape,u.combineAlgebraicallyWithDiscrete(e,n._0,a))}break;case 2:var o=r._0;switch(0|n.TAG){case 0:break;case 1:return t._1(u.T.toShape,u.combineAlgebraicallyWithDiscrete(e,o,n._0));case 2:return t._1(u.T.toShape,u.combineAlgebraically(e,o,n._0))}}return t._1(i.T.toShape,i.combineAlgebraically(e,p(r),p(n)))}function y(e,t,n,a,o){var s=void 0!==e?e:function(e,r){},l=void 0!==t?t:function(e,r){};switch(0|a.TAG){case 0:break;case 1:switch(0|o.TAG){case 1:return r({TAG:1,_0:c.combinePointwise(s,l,n,a._0,o._0)},Symbol.for("name"),"Discrete")}break;case 2:switch(0|o.TAG){case 0:case 1:break;case 2:return r({TAG:2,_0:u.combinePointwise(s,l,void 0,n,a._0,o._0)},Symbol.for("name"),"Continuous")}}return r({TAG:0,_0:i.combinePointwise(s,l,n,p(a),p(o))},Symbol.for("name"),"Mixed")}function v(e){var r=[t._1(i.T.xToY,e),t._1(c.T.xToY,e),t._1(u.T.xToY,e)];return function(e){return l(r,e)}}function x(e){return e}function h(e,r){return T([t._1(i.T.downsample,e),t._1(c.T.downsample,e),t._1(u.T.downsample,e)],r)}function d(e,r,n){return T([t._2(i.T.truncate,e,r),t._2(c.T.truncate,e,r),t._2(u.T.truncate,e,r)],n)}var A=i.T.normalize,I=c.T.normalize,w=u.T.normalize,S=[A,I,w];function G(e){return T(S,e)}function C(e,r){return T([t._1(i.T.updateIntegralCache,e),t._1(c.T.updateIntegralCache,e),t._1(u.T.updateIntegralCache,e)],r)}var Y=i.T.toContinuous,D=c.T.toContinuous,X=u.T.toContinuous,j=[Y,D,X];function k(e){return l(j,e)}var M=i.T.toDiscrete,P=c.T.toDiscrete,q=u.T.toDiscrete,F=[M,P,q];function z(e){return l(F,e)}var N=i.T.toDiscreteProbabilityMassFraction,E=c.T.toDiscreteProbabilityMassFraction,L=u.T.toDiscreteProbabilityMassFraction,V=[N,E,L];function W(e){return l(V,e)}var $=i.T.minX,O=c.T.minX,R=u.T.minX,B=[$,O,R];function H(e){return l(B,e)}var J=i.T.Integral.get,K=c.T.Integral.get,Q=u.T.Integral.get,U=[J,K,Q];function Z(e){return l(U,e)}var ee=i.T.Integral.sum,re=c.T.Integral.sum,te=u.T.Integral.sum,ne=[ee,re,te];function ae(e){return l(ne,e)}function oe(e){var r=[t._1(i.T.Integral.xToY,e),t._1(c.T.Integral.xToY,e),t._1(u.T.Integral.xToY,e)];return function(e){return l(r,e)}}function ie(e){var r=[t._1(i.T.Integral.yToX,e),t._1(c.T.Integral.yToX,e),t._1(u.T.Integral.yToX,e)];return function(e){return l(r,e)}}var ce=i.T.maxX,ue=c.T.maxX,se=u.T.maxX,le=[ce,ue,se];function Te(e){return l(le,e)}function _e(e,r,n){var a=void 0!==e?e:function(e){},o=void 0!==r?r:function(e){},s=[t._3(i.T.mapY,a,o,n),t._3(c.T.mapY,a,o,n),t._3(u.T.mapY,a,o,n)];return function(e){return T(s,e)}}function me(e){switch(0|e.TAG){case 0:return t._1(i.T.mean,e._0);case 1:return t._1(c.T.mean,e._0);case 2:return t._1(u.T.mean,e._0)}}function fe(e){switch(0|e.TAG){case 0:return t._1(i.T.variance,e._0);case 1:return t._1(c.T.variance,e._0);case 2:return t._1(u.T.variance,e._0)}}var be=s.Dist({minX:H,maxX:Te,mapY:_e,xToY:v,toShape:x,toContinuous:k,toDiscrete:z,normalize:G,toDiscreteProbabilityMassFraction:W,downsample:h,truncate:d,updateIntegralCache:C,integral:Z,integralEndY:ae,integralXtoY:oe,integralYtoX:ie,mean:me,variance:fe});function pe(e,r){var n=t._2(be.xToY,e,r);return n.continuous+n.discrete}var ge=be.Integral.yToX,ye=be.Integral.xToY;function ve(e,r){for(var n=a.make(e,0),o=0;o1e4?"Sampling":"Analytical"}function y(r,e,i,u){var a=o.R.merge(t.SamplingDistribution.renderIfIsNotSamplingDistribution(r,i),t.SamplingDistribution.renderIfIsNotSamplingDistribution(r,u));return n._2(o.R.bind,a,function(n){var o=n[1],i=n[0];return"Sampling"===d(i,o)?t.SamplingDistribution.combineShapesUsingSampling(r,e,i,o):b(r,e,i,o)})}function p(i,t,u,a){var s=m(t,u,a);return n._2(o.R.bind,s,function(n){return"object"===e(n)&&"SymbolicDist"===n.NAME?r({TAG:0,_0:n},Symbol.for("name"),"Ok"):y(i,t,u,a)})}var E={tryAnalyticalSimplification:m,combinationByRendering:b,nodeScore:l,choose:d,combine:y,operationToLeaf:p};function S(o,t,u){var s=n._2(f.ExpressionTree.Render.render,o,t),A=n._2(f.ExpressionTree.Render.render,o,u);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var c=s._0;if("object"===e(c)&&"RenderedDist"===c.NAME&&0===A.TAG){var m=A._0;return"object"===e(m)&&"RenderedDist"===m.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:i.combinePointwise(function(r,e){return r+e},function(r,e){return a.combinePointwise(void 0,void 0,"CDF",function(r,e){return r+e},r,e)},function(r,e){return r+e},c.VAL,m.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error")}return 0===A.TAG?r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error"):r({TAG:1,_0:A._0},Symbol.for("name"),"Error")}function _(o,t,u,a){var s=n._2(f.ExpressionTree.Render.render,t,u),A=n._2(f.ExpressionTree.Render.render,t,a);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var c=s._0;if("object"===e(c)&&"RenderedDist"===c.NAME&&0===A.TAG){var m=A._0;return"object"===e(m)&&"RenderedDist"===m.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:i.combinePointwise(void 0,void 0,o,c.VAL,m.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error")}return 0===A.TAG?r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error"):r({TAG:1,_0:A._0},Symbol.for("name"),"Error")}function T(r,e,n,o){return"Add"===e?S(r,n,o):_("Exponentiate"===e?function(r,e){return Math.pow(r,e)}:function(r,e){return r*e},r,n,o)}var v={pointwiseAdd:S,pointwiseCombine:_,operationToLeaf:T};function L(r,n,o){if(void 0!==r){if(void 0!==n&&r>n)return{NAME:"Error",VAL:"Left truncation bound must be smaller than right truncation bound."}}else if(void 0===n)return{NAME:"Solution",VAL:o};if("object"!==e(o))return"NoSolution";if("SymbolicDist"!==o.NAME)return"NoSolution";var i=o.VAL;return"object"===e(i)&&"Uniform"===i.NAME?{NAME:"Solution",VAL:{NAME:"SymbolicDist",VAL:{NAME:"Uniform",VAL:A.Uniform.truncate(r,n,i.VAL)}}}:"NoSolution"}function R(o,t,u,a){var s=n._2(f.ExpressionTree.Render.ensureIsRendered,o,a);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var A=s._0;return"object"===e(A)&&"RenderedDist"===A.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:n._3(i.T.truncate,t,u,A.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Could not truncate distribution."},Symbol.for("name"),"Error")}function V(n,o,i,t){var u=L(o,i,t);return"object"===e(u)?"Error"===u.NAME?r({TAG:1,_0:u.VAL},Symbol.for("name"),"Error"):r({TAG:0,_0:u.VAL},Symbol.for("name"),"Ok"):R(n,o,i,t)}var N={trySimplification:L,truncateAsShape:R,operationToLeaf:V};function G(o,t){if("object"!==e(t))return f.ExpressionTree.evaluateAndRetry(o,G,t);var u=t.NAME;return"SymbolicDist"===u?r({TAG:0,_0:t},Symbol.for("name"),"Ok"):"RenderedDist"===u?r({TAG:0,_0:{NAME:"RenderedDist",VAL:n._1(i.T.normalize,t.VAL)}},Symbol.for("name"),"Ok"):f.ExpressionTree.evaluateAndRetry(o,G,t)}var M={operationToLeaf:G};function D(r,e,o){return n._4(s.$$Function.Ts.findByNameAndRun,c.all,r,e,o)}function g(r,e,i){var u=n._2(f.ExpressionTree.Environment.getFunction,e.environment,r);return n._2(o.R.bind,u,function(r){return t.$$Function.run(e,i,[r[0],r[1]])})}function j(r,e,i){return n._2(o.O.$$default,g(e,r,i),D(e,r,i))}function x(r,e,i){var t=n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(e){return n._2(r.evaluateNode,r,e)},i));return n._2(o.R.bind,t,function(n){return j(r,e,n)})}var O={_runHardcodedFunction:D,_runLocalFunction:g,_runWithEvaluatedInputs:j,run:x};function h(n,o){if("object"!==e(o))return f.ExpressionTree.evaluateAndRetry(n,h,o);var i=o.NAME;return"SymbolicDist"===i?r({TAG:0,_0:{NAME:"RenderedDist",VAL:A.T.toShape(n.samplingInputs.shapeLength,o.VAL)}},Symbol.for("name"),"Ok"):"Function"===i?r({TAG:1,_0:"Cannot render a function"},Symbol.for("name"),"Error"):"RenderedDist"===i?r({TAG:0,_0:o},Symbol.for("name"),"Ok"):f.ExpressionTree.evaluateAndRetry(n,h,o)}var w={operationToLeaf:h};function k(e,i){var t=i.NAME;if("RenderedDist"===t||"Function"===t||"SymbolicDist"===t)return r({TAG:0,_0:i},Symbol.for("name"),"Ok");if("FunctionCall"===t){var u=i.VAL,a=x(e,u[0],u[1]);return n._2(o.R.bind,a,function(r){return k(e,r)})}if("AlgebraicCombination"===t){var s=i.VAL;return p(e,s[0],s[1],s[2])}if("PointwiseCombination"===t){var A=i.VAL;return T(e,A[0],A[1],A[2])}if("Symbol"===t){var c=i.VAL,m=o.O.toResult("Undeclared variable "+c,n._2(f.ExpressionTree.Environment.get,e.environment,c));return n._2(o.R.bind,m,function(r){return k(e,r)})}if("Truncate"!==t)return"Hash"===t?n._2(o.R.fmap,function(r){return{NAME:"Hash",VAL:r}},n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(r){var i=r[0];return n._2(o.R.fmap,function(r){return[i,r]},k(e,r[1]))},i.VAL))):"Array"===t?n._2(o.R.fmap,function(r){return{NAME:"Array",VAL:r}},n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(r){return k(e,r)},i.VAL))):"Render"===t?h(e,i.VAL):G(e,i.VAL);var b=i.VAL;return V(e,b[0],b[1],b[2])}exports.AlgebraicCombination=E,exports.PointwiseCombination=v,exports.Truncate=N,exports.Normalize=M,exports.FunctionCall=O,exports.Render=w,exports.toLeaf=k; -},{"rescript/lib/js/curry.js":"NSLD","../utility/E.bs.js":"xX5m","../distribution/Shape.bs.js":"wbI6","./PTypes.bs.js":"uF38","../distribution/XYShape.bs.js":"Lf2V","../distribution/Continuous.bs.js":"CVcq","../typeSystem/TypeSystem.bs.js":"TKgk","../symbolic/SymbolicDist.bs.js":"wl7Z","./ExpressionTypes.bs.js":"OH0m","../typeSystem/HardcodedFunctions.bs.js":"BBdU"}],"H74a":[function(require,module,exports) { +"use strict";function r(r,e,o){return e in r?Object.defineProperty(r,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[e]=o,r}function e(r){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var o=require("rescript/lib/js/curry.js"),n=require("rescript/lib/js/belt_Array.js"),t=require("rescript/lib/js/caml_splice_call.js"),i=require("../utility/E.bs.js"),a=require("../expressionTree/PTypes.bs.js"),u=require("../expressionTree/ASTTypes.bs.js"),f=require("../expressionTree/ExpressionTreeBasic.bs.js"),A=u.ExpressionTree.getFloat;function m(r){var e=r.NAME;return"Float"===e?"Float: "+r.VAL.toString():"RenderedDist"===e?"[rendered Shape]":"Hash"===e?"{"+t.spliceObjApply(",","concat",[o._2(i.A.fmap,function(r){return r[0]+":"+m(r[1])},r.VAL)])+"}":"Array"===e?"["+t.spliceObjApply(",","concat",[o._2(i.A.fmap,m,r.VAL)])+"]":"[sampling dist]"}function s(n){if("object"!==e(n))return r({TAG:1,_0:"Wrong type: "+f.toString(n)},Symbol.for("name"),"Error");var t=n.NAME;if("SymbolicDist"!==t)return"RenderedDist"===t?r({TAG:0,_0:{NAME:"RenderedDist",VAL:n.VAL}},Symbol.for("name"),"Ok"):"Hash"===t?o._2(i.R.fmap,function(r){return{NAME:"Hash",VAL:r}},o._1(i.A.R.firstErrorOrOpen,o._2(i.A.fmap,function(r){var e=r[0];return o._2(i.R.fmap,function(r){return[e,r]},s(r[1]))},n.VAL))):"Array"===t?o._2(i.R.fmap,function(r){return{NAME:"Array",VAL:r}},o._1(i.A.R.firstErrorOrOpen,o._2(i.A.fmap,s,n.VAL))):r({TAG:1,_0:"Wrong type: "+f.toString(n)},Symbol.for("name"),"Error");var a=n.VAL;return"object"===e(a)&&"Float"===a.NAME?r({TAG:0,_0:{NAME:"Float",VAL:a.VAL}},Symbol.for("name"),"Ok"):r({TAG:0,_0:{NAME:"SamplingDist",VAL:{NAME:"SymbolicDist",VAL:a}}},Symbol.for("name"),"Ok")}function p(n,t,f){if("object"===e(t)){if("Array"===t.NAME){if("object"!==e(f))return r({TAG:1,_0:"fromNodeWithTypeCoercion error, sorry."},Symbol.for("name"),"Error");if("Array"!==f.NAME)return r({TAG:1,_0:"fromNodeWithTypeCoercion error, sorry."},Symbol.for("name"),"Error");var m=t.VAL;return o._2(i.R.fmap,function(r){return{NAME:"Array",VAL:r}},o._1(i.A.R.firstErrorOrOpen,o._2(i.A.fmap,function(r){return p(n,m,r)},f.VAL)))}if("object"!==e(f))return r({TAG:1,_0:"fromNodeWithTypeCoercion error, sorry."},Symbol.for("name"),"Error");if("Hash"!==f.NAME)return r({TAG:1,_0:"fromNodeWithTypeCoercion error, sorry."},Symbol.for("name"),"Error");var y=f.VAL,c=o._2(i.A.fmap,function(r){var e=r[0];return[e,r[1],o._2(u.ExpressionTree.Hash.getByName,y,e)]},t.VAL);return o._2(i.R.fmap,function(r){return{NAME:"Hash",VAL:r}},o._1(i.A.R.firstErrorOrOpen,o._2(i.A.fmap,function(e){var t=e[2];if(void 0===t)return r({TAG:1,_0:"Hash parameter not present in hash."},Symbol.for("name"),"Error");var a=e[0];return o._2(i.R.fmap,function(r){return[a,r]},p(n,e[1],t))},c)))}if("Float"===t){var l=A(f);return void 0!==l?r({TAG:0,_0:{NAME:"Float",VAL:l}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Type Error: Expected float."},Symbol.for("name"),"Error")}if("SamplingDistribution"===t){var b=a.SamplingDistribution.renderIfIsNotSamplingDistribution(n,f);return o._2(i.R.bind,b,s)}var _=o._2(u.ExpressionTree.Render.render,n,f);return o._2(i.R.bind,_,s)}function y(o){return"object"===e(o)&&"Float"===o.NAME?r({TAG:0,_0:o.VAL},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Not a float"},Symbol.for("name"),"Error")}function c(o){return"object"===e(o)&&"Array"===o.NAME?r({TAG:0,_0:o.VAL},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Not an array"},Symbol.for("name"),"Error")}function l(o){return"object"===e(o)&&"Hash"===o.NAME?r({TAG:0,_0:o.VAL},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Not a named item"},Symbol.for("name"),"Error")}function b(o){if("object"!==e(o))return r({TAG:1,_0:"Cannot be converted into a distribution: "+m(o)},Symbol.for("name"),"Error");var n=o.NAME;if("SamplingDist"!==n)return"Float"===n?r({TAG:0,_0:{NAME:"SymbolicDist",VAL:{NAME:"Float",VAL:o.VAL}}},Symbol.for("name"),"Ok"):"RenderedDist"===n?r({TAG:0,_0:{NAME:"RenderedDist",VAL:o.VAL}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Cannot be converted into a distribution: "+m(o)},Symbol.for("name"),"Error");var t=o.VAL;return"RenderedDist"===t.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:t.VAL}},Symbol.for("name"),"Ok"):r({TAG:0,_0:{NAME:"SymbolicDist",VAL:t.VAL}},Symbol.for("name"),"Ok")}var _={toString:m,fromNode:s,fromNodeWithTypeCoercion:p,toFloat:y,toArray:c,toNamed:l,toDist:b};function T(r,e,o,n,t,i){return{name:r,inputTypes:e,outputType:o,run:n,shouldCoerceTypes:void 0===t||t}}function E(e,o){var n=i.A.length(o.inputTypes),t=i.A.length(e);return n===t?r({TAG:0,_0:e},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Wrong number of inputs. Expected"+i.I.toString(n)+". Got:"+i.I.toString(t)},Symbol.for("name"),"Error")}function d(r,e,t,a){return o._1(i.A.R.firstErrorOrOpen,o._2(i.A.fmap,function(e){var o=e[1];return t?p(r,e[0],o):s(o)},n.zip(e,a)))}function S(r,e,n){var t=n.shouldCoerceTypes,a=n.inputTypes;return o._2(i.R.bind,E(e,n),function(e){return d(r,a,t,e)})}function N(e,n,t){var a=o._2(i.R.bind,S(e,n,t),t.run);return 0===a.TAG?r({TAG:0,_0:a._0},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Function "+t.name+" error: "+a._0},Symbol.for("name"),"Error")}var V={make:T,_inputLengthCheck:E,_coerceInputNodes:d,inputsToTypedValues:S,run:N};function L(r,e){return n.getBy(r,function(r){return r.name===e})}function G(r,e,n,t){return o._2(i.O.fmap,function(r){return N(n,t,r)},L(r,e))}var v={findByName:L,findByNameAndRun:G},O={T:V,Ts:v};exports.getFloat=A,exports.TypedValue=_,exports.$$Function=O; +},{"rescript/lib/js/curry.js":"NSLD","rescript/lib/js/belt_Array.js":"yUxI","rescript/lib/js/caml_splice_call.js":"N3i9","../utility/E.bs.js":"xX5m","../expressionTree/PTypes.bs.js":"uF38","../expressionTree/ASTTypes.bs.js":"OH0m","../expressionTree/ExpressionTreeBasic.bs.js":"lpIF"}],"BBdU":[function(require,module,exports) { +"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(t)}function t(r,t,e){return t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}var e=require("rescript/lib/js/curry.js"),n=require("rescript/lib/js/caml_splice_call.js"),i=require("../utility/E.bs.js"),o=require("../distribution/Shape.bs.js"),a=require("../expressionTree/Operation.bs.js"),u=require("./TypeSystem.bs.js"),l=require("../symbolic/SymbolicDist.bs.js"),m=require("../expressionTree/ASTTypes.bs.js");function s(r){var o=n.spliceObjApply(",","concat",[e._2(i.A.fmap,u.TypedValue.toString,r)]);return console.log("Inputs were",o,r),t({TAG:1,_0:"Wrong inputs. The inputs were:"+o},Symbol.for("name"),"Error")}function A(r,e){return r<=0&&r1e4?"Sampling":"Analytical"}function y(r,e,i,u){var a=o.R.merge(t.SamplingDistribution.renderIfIsNotSamplingDistribution(r,i),t.SamplingDistribution.renderIfIsNotSamplingDistribution(r,u));return n._2(o.R.bind,a,function(n){var o=n[1],i=n[0];return"Sampling"===d(i,o)?t.SamplingDistribution.combineShapesUsingSampling(r,e,i,o):b(r,e,i,o)})}function p(i,t,u,a){var s=m(t,u,a);return n._2(o.R.bind,s,function(n){return"object"===e(n)&&"SymbolicDist"===n.NAME?r({TAG:0,_0:n},Symbol.for("name"),"Ok"):y(i,t,u,a)})}var E={tryAnalyticalSimplification:m,combinationByRendering:b,nodeScore:l,choose:d,combine:y,operationToLeaf:p};function S(o,t,u){var s=n._2(f.ExpressionTree.Render.render,o,t),A=n._2(f.ExpressionTree.Render.render,o,u);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var c=s._0;if("object"===e(c)&&"RenderedDist"===c.NAME&&0===A.TAG){var m=A._0;return"object"===e(m)&&"RenderedDist"===m.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:i.combinePointwise(function(r,e){return r+e},function(r,e){return a.combinePointwise(void 0,void 0,"CDF",function(r,e){return r+e},r,e)},function(r,e){return r+e},c.VAL,m.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error")}return 0===A.TAG?r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error"):r({TAG:1,_0:A._0},Symbol.for("name"),"Error")}function _(o,t,u,a){var s=n._2(f.ExpressionTree.Render.render,t,u),A=n._2(f.ExpressionTree.Render.render,t,a);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var c=s._0;if("object"===e(c)&&"RenderedDist"===c.NAME&&0===A.TAG){var m=A._0;return"object"===e(m)&&"RenderedDist"===m.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:i.combinePointwise(void 0,void 0,o,c.VAL,m.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error")}return 0===A.TAG?r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error"):r({TAG:1,_0:A._0},Symbol.for("name"),"Error")}function T(r,e,n,o){return"Add"===e?S(r,n,o):_("Exponentiate"===e?function(r,e){return Math.pow(r,e)}:function(r,e){return r*e},r,n,o)}var v={pointwiseAdd:S,pointwiseCombine:_,operationToLeaf:T};function L(r,n,o){if(void 0!==r){if(void 0!==n&&r>n)return{NAME:"Error",VAL:"Left truncation bound must be smaller than right truncation bound."}}else if(void 0===n)return{NAME:"Solution",VAL:o};if("object"!==e(o))return"NoSolution";if("SymbolicDist"!==o.NAME)return"NoSolution";var i=o.VAL;return"object"===e(i)&&"Uniform"===i.NAME?{NAME:"Solution",VAL:{NAME:"SymbolicDist",VAL:{NAME:"Uniform",VAL:A.Uniform.truncate(r,n,i.VAL)}}}:"NoSolution"}function R(o,t,u,a){var s=n._2(f.ExpressionTree.Render.ensureIsRendered,o,a);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var A=s._0;return"object"===e(A)&&"RenderedDist"===A.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:n._3(i.T.truncate,t,u,A.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Could not truncate distribution."},Symbol.for("name"),"Error")}function V(n,o,i,t){var u=L(o,i,t);return"object"===e(u)?"Error"===u.NAME?r({TAG:1,_0:u.VAL},Symbol.for("name"),"Error"):r({TAG:0,_0:u.VAL},Symbol.for("name"),"Ok"):R(n,o,i,t)}var N={trySimplification:L,truncateAsShape:R,operationToLeaf:V};function G(o,t){if("object"!==e(t))return f.ExpressionTree.evaluateAndRetry(o,G,t);var u=t.NAME;return"SymbolicDist"===u?r({TAG:0,_0:t},Symbol.for("name"),"Ok"):"RenderedDist"===u?r({TAG:0,_0:{NAME:"RenderedDist",VAL:n._1(i.T.normalize,t.VAL)}},Symbol.for("name"),"Ok"):f.ExpressionTree.evaluateAndRetry(o,G,t)}var M={operationToLeaf:G};function D(r,e,o){return n._4(s.$$Function.Ts.findByNameAndRun,c.all,r,e,o)}function g(r,e,i){var u=n._2(f.ExpressionTree.Environment.getFunction,e.environment,r);return n._2(o.R.bind,u,function(r){return t.$$Function.run(e,i,[r[0],r[1]])})}function j(r,e,i){return n._2(o.O.$$default,g(e,r,i),D(e,r,i))}function x(r,e,i){var t=n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(e){return n._2(r.evaluateNode,r,e)},i));return n._2(o.R.bind,t,function(n){return j(r,e,n)})}var O={_runHardcodedFunction:D,_runLocalFunction:g,_runWithEvaluatedInputs:j,run:x};function h(n,o){if("object"!==e(o))return f.ExpressionTree.evaluateAndRetry(n,h,o);var i=o.NAME;return"SymbolicDist"===i?r({TAG:0,_0:{NAME:"RenderedDist",VAL:A.T.toShape(n.samplingInputs.shapeLength,o.VAL)}},Symbol.for("name"),"Ok"):"Function"===i?r({TAG:1,_0:"Cannot render a function"},Symbol.for("name"),"Error"):"RenderedDist"===i?r({TAG:0,_0:o},Symbol.for("name"),"Ok"):f.ExpressionTree.evaluateAndRetry(n,h,o)}var w={operationToLeaf:h};function k(e,i){var t=i.NAME;if("RenderedDist"===t||"Function"===t||"SymbolicDist"===t)return r({TAG:0,_0:i},Symbol.for("name"),"Ok");if("FunctionCall"===t){var u=i.VAL,a=x(e,u[0],u[1]);return n._2(o.R.bind,a,function(r){return k(e,r)})}if("AlgebraicCombination"===t){var s=i.VAL;return p(e,s[0],s[1],s[2])}if("PointwiseCombination"===t){var A=i.VAL;return T(e,A[0],A[1],A[2])}if("Symbol"===t){var c=i.VAL,m=o.O.toResult("Undeclared variable "+c,n._2(f.ExpressionTree.Environment.get,e.environment,c));return n._2(o.R.bind,m,function(r){return k(e,r)})}if("Truncate"!==t)return"Hash"===t?n._2(o.R.fmap,function(r){return{NAME:"Hash",VAL:r}},n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(r){var i=r[0];return n._2(o.R.fmap,function(r){return[i,r]},k(e,r[1]))},i.VAL))):"Array"===t?n._2(o.R.fmap,function(r){return{NAME:"Array",VAL:r}},n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(r){return k(e,r)},i.VAL))):"Render"===t?h(e,i.VAL):G(e,i.VAL);var b=i.VAL;return V(e,b[0],b[1],b[2])}exports.AlgebraicCombination=E,exports.PointwiseCombination=v,exports.Truncate=N,exports.Normalize=M,exports.FunctionCall=O,exports.Render=w,exports.toLeaf=k; +},{"rescript/lib/js/curry.js":"NSLD","../utility/E.bs.js":"xX5m","../distribution/Shape.bs.js":"wbI6","./PTypes.bs.js":"uF38","../distribution/XYShape.bs.js":"Lf2V","../distribution/Continuous.bs.js":"CVcq","../typeSystem/TypeSystem.bs.js":"TKgk","../symbolic/SymbolicDist.bs.js":"wl7Z","./ASTTypes.bs.js":"OH0m","../typeSystem/HardcodedFunctions.bs.js":"BBdU"}],"H74a":[function(require,module,exports) { "use strict";function e(r){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(r)}function r(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var n=require("./PTypes.bs.js"),t=require("./ExpressionTreeBasic.bs.js"),o=require("./ExpressionTreeEvaluator.bs.js");function u(e,r){return{samplingInputs:e,environment:r,evaluateNode:o.toLeaf}}function i(e,r,n){return o.toLeaf({samplingInputs:e,environment:r,evaluateNode:o.toLeaf},n)}function a(n,t,o){var u=i(n,t,o);if(0!==u.TAG)return r({TAG:1,_0:u._0},Symbol.for("name"),"Error");var a=u._0;return"object"===e(a)&&"RenderedDist"===a.NAME?r({TAG:0,_0:a.VAL},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Rendering failed."},Symbol.for("name"),"Error")}function s(e,r,t,u){var i={samplingInputs:e,environment:r,evaluateNode:o.toLeaf};return n.$$Function.run(i,t,u)}var f=t.toString;exports.toString=f,exports.envs=u,exports.toLeaf=i,exports.toShape=a,exports.runFunction=s; },{"./PTypes.bs.js":"uF38","./ExpressionTreeBasic.bs.js":"lpIF","./ExpressionTreeEvaluator.bs.js":"NgRJ"}],"uZ2e":[function(require,module,exports) { -"use strict";function e(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=require("rescript/lib/js/array.js"),t=require("rescript/lib/js/curry.js"),o=require("rescript/lib/js/caml_option.js"),i=require("rescript/lib/js/belt_MapString.js"),u=require("./utility/E.bs.js"),s=require("./distribution/DistPlus.bs.js"),a=require("./expressionTree/MathJsParser.bs.js"),l=require("./expressionTree/ExpressionTree.bs.js"),m=require("./expressionTree/ExpressionTypes.bs.js"),p={},f={sampleCount:void 0,outputXYPoints:void 0,kernelWidth:void 0,shapeLength:void 0};function c(e,r,n,t){return{squiggleString:r,samplingInputs:void 0!==e?e:f,environment:void 0!==n?o.valFromOption(n):m.ExpressionTree.Environment.empty}}var d={SamplingInputs:p,defaultRecommendedLength:100,defaultShouldDownsample:!0,empty:f,make:c};function b(e,r,n){return{squiggleString:e.squiggleString,samplingInputs:e.samplingInputs,environment:t._3(m.ExpressionTree.Environment.update,e.environment,r,function(e){return n})}}function v(e,r){return{graph:e,shape:r}}function A(e){return{sampleCount:t._2(u.O.$$default,1e4,e.samplingInputs.sampleCount),outputXYPoints:t._2(u.O.$$default,1e4,e.samplingInputs.outputXYPoints),kernelWidth:e.samplingInputs.kernelWidth,shapeLength:t._2(u.O.$$default,1e4,e.samplingInputs.shapeLength)}}function y(e,r){return l.toLeaf(A(e),e.environment,r)}function g(e,r){var n={contents:e};return t._1(u.A.R.firstErrorOrOpen,t._1(u.A.O.concatSomes,t._2(u.A.fmap,function(e){if("Expression"===e.NAME)return t._2(u.R.fmap,function(e){return[n.contents.environment,e]},y(n.contents,e.VAL));var r=e.VAL;n.contents=b(n.contents,r[0],r[1])},r)))}function _(e){var r=a.fromString(e.squiggleString);return t._2(u.R.bind,r,function(r){return g(e,r)})}function S(e,r){return s.make(r,e.squiggleString,void 0,void 0,void 0)}var T={addVariable:b,makeOutputs:v,makeInputs:A,runNode:y,runProgram:g,inputsToLeaf:_,outputToDistPlus:S};function E(n,t){if("object"!==r(t))return e({TAG:0,_0:t},Symbol.for("name"),"Ok");var o=t.NAME;if("SymbolicDist"!==o&&"Normalize"!==o)return e({TAG:0,_0:t},Symbol.for("name"),"Ok");var i=y(n,{NAME:"Render",VAL:t});if(0!==i.TAG)return e({TAG:1,_0:i._0},Symbol.for("name"),"Error");var u=i._0;return"object"===r(u)&&"RenderedDist"===u.NAME?i:e({TAG:1,_0:"Didn't render, but intended to"},Symbol.for("name"),"Error")}function h(n,o,i){var s=E(n,i);return t._2(u.R.bind,s,function(t){if("object"===r(t)){var i=t.NAME;if("SymbolicDist"===i){var u=t.VAL;if("object"===r(u)&&"Float"===u.NAME)return e({TAG:0,_0:{NAME:"Float",VAL:u.VAL}},Symbol.for("name"),"Ok")}else{if("Function"===i)return e({TAG:0,_0:{NAME:"Function",VAL:[t.VAL,o]}},Symbol.for("name"),"Ok");if("RenderedDist"===i){var s=t.VAL,a=0;switch(0|s.TAG){case 1:var m=s._0.xyShape,p=m.xs;if(1!==p.length)a=2;else{var f=p[0],c=m.ys;if(1!==c.length)a=2;else{if(1===c[0])return e({TAG:0,_0:{NAME:"Float",VAL:f}},Symbol.for("name"),"Ok");a=2}}break;case 0:case 2:a=2}if(2===a)return e({TAG:0,_0:{NAME:"DistPlus",VAL:S(n,s)}},Symbol.for("name"),"Ok")}}}return e({TAG:1,_0:"Didn't output a rendered distribution. Format:"+l.toString(t)},Symbol.for("name"),"Error")})}function x(r,n){if(!n)return e({TAG:0,_0:0},Symbol.for("name"),"Ok");var o=t._1(r,n.hd);if(0!==o.TAG)return e({TAG:1,_0:o._0},Symbol.for("name"),"Error");var i=x(r,n.tl);return 0===i.TAG?e({TAG:0,_0:{hd:o._0,tl:i._0}},Symbol.for("name"),"Ok"):e({TAG:1,_0:i._0},Symbol.for("name"),"Error")}function j(e){var r=_(e);return t._2(u.R.bind,r,function(r){return x(function(r){return h(e,r[0],r[1])},n.to_list(r))})}function L(e,r,n){var o=l.runFunction(A(e),e.environment,n,r),i=e.environment;return t._2(u.R.bind,o,function(r){return h(e,i,r)})}function k(e){return j(c({sampleCount:1e4,outputXYPoints:1e4,kernelWidth:void 0,shapeLength:1e3},e,o.some(i.fromArray([])),void 0))}exports.Inputs=d,exports.Internals=T,exports.renderIfNeeded=E,exports.coersionToExportedTypes=h,exports.mapM=x,exports.evaluateProgram=j,exports.evaluateFunction=L,exports.runAll=k; -},{"rescript/lib/js/array.js":"d4B1","rescript/lib/js/curry.js":"NSLD","rescript/lib/js/caml_option.js":"dzFO","rescript/lib/js/belt_MapString.js":"mO07","./utility/E.bs.js":"xX5m","./distribution/DistPlus.bs.js":"A9pM","./expressionTree/MathJsParser.bs.js":"dGOd","./expressionTree/ExpressionTree.bs.js":"H74a","./expressionTree/ExpressionTypes.bs.js":"OH0m"}],"OXj9":[function(require,module,exports) { +"use strict";function e(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=require("rescript/lib/js/array.js"),t=require("rescript/lib/js/curry.js"),o=require("rescript/lib/js/caml_option.js"),i=require("rescript/lib/js/belt_MapString.js"),u=require("./utility/E.bs.js"),s=require("./distribution/DistPlus.bs.js"),a=require("./expressionTree/MathJsParser.bs.js"),l=require("./expressionTree/ExpressionTree.bs.js"),m=require("./expressionTree/ASTTypes.bs.js"),p={},f={sampleCount:void 0,outputXYPoints:void 0,kernelWidth:void 0,shapeLength:void 0};function c(e,r,n,t){return{squiggleString:r,samplingInputs:void 0!==e?e:f,environment:void 0!==n?o.valFromOption(n):m.ExpressionTree.Environment.empty}}var d={SamplingInputs:p,defaultRecommendedLength:100,defaultShouldDownsample:!0,empty:f,make:c};function b(e,r,n){return{squiggleString:e.squiggleString,samplingInputs:e.samplingInputs,environment:t._3(m.ExpressionTree.Environment.update,e.environment,r,function(e){return n})}}function v(e,r){return{graph:e,shape:r}}function A(e){return{sampleCount:t._2(u.O.$$default,1e4,e.samplingInputs.sampleCount),outputXYPoints:t._2(u.O.$$default,1e4,e.samplingInputs.outputXYPoints),kernelWidth:e.samplingInputs.kernelWidth,shapeLength:t._2(u.O.$$default,1e4,e.samplingInputs.shapeLength)}}function y(e,r){return l.toLeaf(A(e),e.environment,r)}function g(e,r){var n={contents:e};return t._1(u.A.R.firstErrorOrOpen,t._1(u.A.O.concatSomes,t._2(u.A.fmap,function(e){if("Expression"===e.NAME)return t._2(u.R.fmap,function(e){return[n.contents.environment,e]},y(n.contents,e.VAL));var r=e.VAL;n.contents=b(n.contents,r[0],r[1])},r)))}function _(e){var r=a.fromString(e.squiggleString);return t._2(u.R.bind,r,function(r){return g(e,r)})}function S(e,r){return s.make(r,e.squiggleString,void 0,void 0,void 0)}var T={addVariable:b,makeOutputs:v,makeInputs:A,runNode:y,runProgram:g,inputsToLeaf:_,outputToDistPlus:S};function E(n,t){if("object"!==r(t))return e({TAG:0,_0:t},Symbol.for("name"),"Ok");var o=t.NAME;if("SymbolicDist"!==o&&"Normalize"!==o)return e({TAG:0,_0:t},Symbol.for("name"),"Ok");var i=y(n,{NAME:"Render",VAL:t});if(0!==i.TAG)return e({TAG:1,_0:i._0},Symbol.for("name"),"Error");var u=i._0;return"object"===r(u)&&"RenderedDist"===u.NAME?i:e({TAG:1,_0:"Didn't render, but intended to"},Symbol.for("name"),"Error")}function h(n,o,i){var s=E(n,i);return t._2(u.R.bind,s,function(t){if("object"===r(t)){var i=t.NAME;if("SymbolicDist"===i){var u=t.VAL;if("object"===r(u)&&"Float"===u.NAME)return e({TAG:0,_0:{NAME:"Float",VAL:u.VAL}},Symbol.for("name"),"Ok")}else{if("Function"===i)return e({TAG:0,_0:{NAME:"Function",VAL:[t.VAL,o]}},Symbol.for("name"),"Ok");if("RenderedDist"===i){var s=t.VAL,a=0;switch(0|s.TAG){case 1:var m=s._0.xyShape,p=m.xs;if(1!==p.length)a=2;else{var f=p[0],c=m.ys;if(1!==c.length)a=2;else{if(1===c[0])return e({TAG:0,_0:{NAME:"Float",VAL:f}},Symbol.for("name"),"Ok");a=2}}break;case 0:case 2:a=2}if(2===a)return e({TAG:0,_0:{NAME:"DistPlus",VAL:S(n,s)}},Symbol.for("name"),"Ok")}}}return e({TAG:1,_0:"Didn't output a rendered distribution. Format:"+l.toString(t)},Symbol.for("name"),"Error")})}function x(r,n){if(!n)return e({TAG:0,_0:0},Symbol.for("name"),"Ok");var o=t._1(r,n.hd);if(0!==o.TAG)return e({TAG:1,_0:o._0},Symbol.for("name"),"Error");var i=x(r,n.tl);return 0===i.TAG?e({TAG:0,_0:{hd:o._0,tl:i._0}},Symbol.for("name"),"Ok"):e({TAG:1,_0:i._0},Symbol.for("name"),"Error")}function j(e){var r=_(e);return t._2(u.R.bind,r,function(r){return x(function(r){return h(e,r[0],r[1])},n.to_list(r))})}function L(e,r,n){var o=l.runFunction(A(e),e.environment,n,r),i=e.environment;return t._2(u.R.bind,o,function(r){return h(e,i,r)})}function k(e){return j(c({sampleCount:1e4,outputXYPoints:1e4,kernelWidth:void 0,shapeLength:1e3},e,o.some(i.fromArray([])),void 0))}exports.Inputs=d,exports.Internals=T,exports.renderIfNeeded=E,exports.coersionToExportedTypes=h,exports.mapM=x,exports.evaluateProgram=j,exports.evaluateFunction=L,exports.runAll=k; +},{"rescript/lib/js/array.js":"d4B1","rescript/lib/js/curry.js":"NSLD","rescript/lib/js/caml_option.js":"dzFO","rescript/lib/js/belt_MapString.js":"mO07","./utility/E.bs.js":"xX5m","./distribution/DistPlus.bs.js":"A9pM","./expressionTree/MathJsParser.bs.js":"dGOd","./expressionTree/ExpressionTree.bs.js":"H74a","./expressionTree/ASTTypes.bs.js":"OH0m"}],"OXj9":[function(require,module,exports) { var r=require("./ProgramEvaluator.bs"),a=function(a){var u=r.runAll(a);return 0===u.TAG?{tag:"Ok",value:u._0}:{tag:"Error",value:u._0}};exports.runAll=a; },{"./ProgramEvaluator.bs":"uZ2e"}],"Focm":[function(require,module,exports) { var r=require("../distPlus/ProgramEvaluator.gen.js");exports.runMePlease=r.runAll; diff --git a/packages/squiggle-lang/dist/report.html b/packages/squiggle-lang/dist/report.html index bd7966a3..3c25857c 100644 --- a/packages/squiggle-lang/dist/report.html +++ b/packages/squiggle-lang/dist/report.html @@ -42,7 +42,7 @@ margin-bottom: 10px; }