From 98779c127b6bde7fdc3bf79d4cbe6aaab69d8474 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Tue, 15 Feb 2022 15:47:33 -0500 Subject: [PATCH] First pass at file renaming --- .../__tests__/DistTypes__Test.res | 8 +++--- .../__tests__/Distributions__Test.res | 10 +++---- .../__tests__/Hardcoded__Test.res | 2 +- .../squiggle-lang/__tests__/XYShape__Test.res | 6 ++-- packages/squiggle-lang/dist/index.js | 16 +++++------ packages/squiggle-lang/dist/report.html | 2 +- .../src/distPlus/expressionTree/Program.res | 5 ---- packages/squiggle-lang/src/js/index.js | 2 +- .../ProgramEvaluator.gen.js | 0 .../ProgramEvaluator.res | 4 +-- .../interpreter}/ExpressionTree.res | 0 .../interpreter}/ExpressionTreeBasic.res | 3 +- .../interpreter}/ExpressionTreeEvaluator.res | 0 .../interpreter}/ExpressionTypes.res | 6 ++-- .../interpreter}/Operation.res | 0 .../interpreter}/PTypes.res | 8 +++--- .../typeSystem/HardcodedFunctions.res | 0 .../interpreter}/typeSystem/TypeSystem.res | 6 ++-- .../parser}/MathJsParser.res | 0 .../pointSet}/AlgebraicShapeCombination.res | 14 +++++----- .../pointSet}/Continuous.res | 26 ++++++++--------- .../pointSet}/Discrete.res | 28 +++++++++---------- .../pointSet}/DistPlus.res | 10 +++---- .../pointSet}/Distributions.res | 22 +++++++-------- .../pointSet}/Mixed.res | 14 +++++----- .../pointSet}/MixedShapeBuilder.res | 6 ++-- .../pointSet/PointSetTypes.res} | 0 .../pointSet}/Shape.res | 20 ++++++------- .../pointSet}/XYShape.res | 10 +++---- .../sampleSet}/Bandwidth.res | 0 .../sampleSet}/KdeLibrary.js | 0 .../sampleSet}/SamplesToShape.res | 6 ++-- .../symbolicDist}/SymbolicDist.res | 4 +-- .../symbolicDist/SymbolicDistTypes.res} | 0 .../src/{distPlus => rescript}/utility/E.res | 0 .../{distPlus => rescript}/utility/Jstat.res | 0 .../{distPlus => rescript}/utility/Lodash.res | 0 .../utility}/Mathjs.res | 0 .../utility}/MathjsWrapper.js | 0 39 files changed, 117 insertions(+), 121 deletions(-) delete mode 100644 packages/squiggle-lang/src/distPlus/expressionTree/Program.res rename packages/squiggle-lang/src/{distPlus => rescript}/ProgramEvaluator.gen.js (100%) rename packages/squiggle-lang/src/{distPlus => rescript}/ProgramEvaluator.res (97%) rename packages/squiggle-lang/src/{distPlus/expressionTree => rescript/interpreter}/ExpressionTree.res (100%) rename packages/squiggle-lang/src/{distPlus/expressionTree => rescript/interpreter}/ExpressionTreeBasic.res (92%) rename packages/squiggle-lang/src/{distPlus/expressionTree => rescript/interpreter}/ExpressionTreeEvaluator.res (100%) rename packages/squiggle-lang/src/{distPlus/expressionTree => rescript/interpreter}/ExpressionTypes.res (97%) rename packages/squiggle-lang/src/{distPlus/expressionTree => rescript/interpreter}/Operation.res (100%) rename packages/squiggle-lang/src/{distPlus/expressionTree => rescript/interpreter}/PTypes.res (95%) rename packages/squiggle-lang/src/{distPlus => rescript/interpreter}/typeSystem/HardcodedFunctions.res (100%) rename packages/squiggle-lang/src/{distPlus => rescript/interpreter}/typeSystem/TypeSystem.res (97%) rename packages/squiggle-lang/src/{distPlus/expressionTree => rescript/parser}/MathJsParser.res (100%) rename packages/squiggle-lang/src/{distPlus/distribution => rescript/pointSet}/AlgebraicShapeCombination.res (96%) rename packages/squiggle-lang/src/{distPlus/distribution => rescript/pointSet}/Continuous.res (93%) rename packages/squiggle-lang/src/{distPlus/distribution => rescript/pointSet}/Discrete.res (91%) rename packages/squiggle-lang/src/{distPlus/distribution => rescript/pointSet}/DistPlus.res (93%) rename packages/squiggle-lang/src/{distPlus/distribution => rescript/pointSet}/Distributions.res (74%) rename packages/squiggle-lang/src/{distPlus/distribution => rescript/pointSet}/Mixed.res (96%) rename packages/squiggle-lang/src/{distPlus/distribution => rescript/pointSet}/MixedShapeBuilder.res (86%) rename packages/squiggle-lang/src/{distPlus/distribution/DistTypes.res => rescript/pointSet/PointSetTypes.res} (100%) rename packages/squiggle-lang/src/{distPlus/distribution => rescript/pointSet}/Shape.res (93%) rename packages/squiggle-lang/src/{distPlus/distribution => rescript/pointSet}/XYShape.res (98%) rename packages/squiggle-lang/src/{distPlus/samplesRenderer => rescript/sampleSet}/Bandwidth.res (100%) rename packages/squiggle-lang/src/{distPlus/samplesRenderer => rescript/sampleSet}/KdeLibrary.js (100%) rename packages/squiggle-lang/src/{distPlus/samplesRenderer => rescript/sampleSet}/SamplesToShape.res (96%) rename packages/squiggle-lang/src/{distPlus/symbolic => rescript/symbolicDist}/SymbolicDist.res (99%) rename packages/squiggle-lang/src/{distPlus/symbolic/SymbolicTypes.res => rescript/symbolicDist/SymbolicDistTypes.res} (100%) rename packages/squiggle-lang/src/{distPlus => rescript}/utility/E.res (100%) rename packages/squiggle-lang/src/{distPlus => rescript}/utility/Jstat.res (100%) rename packages/squiggle-lang/src/{distPlus => rescript}/utility/Lodash.res (100%) rename packages/squiggle-lang/src/{distPlus/expressionTree => rescript/utility}/Mathjs.res (100%) rename packages/squiggle-lang/src/{distPlus/expressionTree => rescript/utility}/MathjsWrapper.js (100%) 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..76a3fe6a 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 shape: PointSetTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // let makeTest = (~only=false, str, item1, item2) => // only @@ -131,7 +131,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // describe("Discrete", () => { // open Discrete; -// let shape: DistTypes.xyShape = { +// let shape: PointSetTypes.xyShape = { // xs: [|1., 4., 8.|], // ys: [|0.3, 0.5, 0.2|], // }; @@ -209,7 +209,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // describe("Mixed", () => { // open Distributions.Mixed; -// let discreteShape: DistTypes.xyShape = { +// let discreteShape: PointSetTypes.xyShape = { // xs: [|1., 4., 8.|], // ys: [|0.3, 0.5, 0.2|], // }; @@ -309,7 +309,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // describe("Distplus", () => { // open DistPlus; -// let discreteShape: DistTypes.xyShape = { +// let discreteShape: PointSetTypes.xyShape = { // xs: [|1., 4., 8.|], // ys: [|0.3, 0.5, 0.2|], // }; @@ -382,7 +382,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // let variance = stdev ** 2.0; // let numSamples = 10000; // open Distributions.Shape; -// let normal: SymbolicTypes.symbolicDist = `Normal({mean, stdev}); +// let normal: SymbolicDistTypes.symbolicDist = `Normal({mean, stdev}); // let normalShape = ExpressionTree.toShape(numSamples, `SymbolicDist(normal)); // let lognormal = SymbolicDist.Lognormal.fromMeanAndStdev(mean, stdev); // let lognormalShape = ExpressionTree.toShape(numSamples, `SymbolicDist(lognormal)); diff --git a/packages/squiggle-lang/__tests__/Hardcoded__Test.res b/packages/squiggle-lang/__tests__/Hardcoded__Test.res index 482019bc..e1346ba3 100644 --- a/packages/squiggle-lang/__tests__/Hardcoded__Test.res +++ b/packages/squiggle-lang/__tests__/Hardcoded__Test.res @@ -28,7 +28,7 @@ let evalParams: ExpressionTypes.ExpressionTree.evaluationParams = { evaluateNode: ExpressionTreeEvaluator.toLeaf, }; -let shape1: DistTypes.xyShape = {xs: [|1., 4., 8.|], ys: [|0.2, 0.4, 0.8|]}; +let shape1: PointSetTypes.xyShape = {xs: [|1., 4., 8.|], ys: [|0.2, 0.4, 0.8|]}; describe("XYShapes", () => { describe("logScorePoint", () => { diff --git a/packages/squiggle-lang/__tests__/XYShape__Test.res b/packages/squiggle-lang/__tests__/XYShape__Test.res index 10ee1c20..5ccec208 100644 --- a/packages/squiggle-lang/__tests__/XYShape__Test.res +++ b/packages/squiggle-lang/__tests__/XYShape__Test.res @@ -6,14 +6,14 @@ 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 shape1: PointSetTypes.xyShape = {xs: [1., 4., 8.], ys: [0.2, 0.4, 0.8]} -let shape2: DistTypes.xyShape = { +let shape2: PointSetTypes.xyShape = { xs: [1., 5., 10.], ys: [0.2, 0.5, 0.8], } -let shape3: DistTypes.xyShape = { +let shape3: PointSetTypes.xyShape = { xs: [1., 20., 50.], ys: [0.2, 0.5, 0.8], } diff --git a/packages/squiggle-lang/dist/index.js b/packages/squiggle-lang/dist/index.js index 1297d6f0..f1be24b8 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;o