diff --git a/__tests__/Foo/Foo__Test.re b/__tests__/Foo/Foo__Test.re
index 4c52fccf..e4471e53 100644
--- a/__tests__/Foo/Foo__Test.re
+++ b/__tests__/Foo/Foo__Test.re
@@ -1,15 +1,12 @@
open Jest;
open Expect;
-let shape: DistributionTypes.xyShape = {
- xs: [|1., 4., 8.|],
- ys: [|8., 9., 2.|],
-};
+let shape: DistTypes.xyShape = {xs: [|1., 4., 8.|], ys: [|8., 9., 2.|]};
-let step: DistributionTypes.xyShape = {
+let step: DistTypes.xyShape = {
xs: [|1., 4., 8.|],
ys: [|8., 17., 19.|],
-} /* }*/;
+} /* }*/ /* )*/;
// describe("Shape", () =>
// describe("XYShape", () => {
@@ -17,5 +14,4 @@ let step: DistributionTypes.xyShape = {
// expect(XYShape.ySum(shape)) |> toEqual(19.0)
// );
// test("#yFOo", () =>
-// expect(Discrete.integrate(shape)) |> toEqual(step)
-// );
\ No newline at end of file
+// expect(Discrete.integrate(shape)) |> toEqual(step)
\ No newline at end of file
diff --git a/src/components/charts/CdfChart__Base.re b/src/components/charts/CdfChart__Base.re
deleted file mode 100644
index 8fd8151d..00000000
--- a/src/components/charts/CdfChart__Base.re
+++ /dev/null
@@ -1,59 +0,0 @@
-[@bs.module "./cdfChartReact.js"]
-external cdfChart: ReasonReact.reactClass = "default";
-
-type primaryDistribution =
- option({
- .
- "xs": array(float),
- "ys": array(float),
- });
-
-type discrete =
- option({
- .
- "xs": array(float),
- "ys": array(float),
- });
-
-[@react.component]
-let make =
- (
- ~height=?,
- ~marginBottom=?,
- ~marginTop=?,
- ~maxX=?,
- ~minX=?,
- ~onHover=(f: float) => (),
- ~continuous=?,
- ~discrete=?,
- ~scale=?,
- ~showDistributionLines=?,
- ~showDistributionYAxis=?,
- ~showVerticalLine=?,
- ~timeScale=?,
- ~verticalLine=?,
- ~children=[||],
- ) =>
- ReasonReact.wrapJsForReason(
- ~reactClass=cdfChart,
- ~props=
- makeProps(
- ~height?,
- ~marginBottom?,
- ~marginTop?,
- ~maxX?,
- ~minX?,
- ~onHover,
- ~continuous?,
- ~discrete?,
- ~scale?,
- ~showDistributionLines?,
- ~showDistributionYAxis?,
- ~showVerticalLine?,
- ~timeScale?,
- ~verticalLine?,
- (),
- ),
- children,
- )
- |> ReasonReact.element;
\ No newline at end of file
diff --git a/src/components/charts/ChartSimple.re b/src/components/charts/ChartSimple.re
deleted file mode 100644
index 37f8697c..00000000
--- a/src/components/charts/ChartSimple.re
+++ /dev/null
@@ -1,24 +0,0 @@
-module Styles = {
- open Css;
- let graph = chartColor =>
- style([
- selector(".axis", [fontSize(`px(9))]),
- selector(".domain", [display(`none)]),
- selector(".tick line", [display(`none)]),
- selector(".tick text", [color(`hex("bfcad4"))]),
- selector(".chart .area-path", [SVG.fill(chartColor)]),
- ]);
-};
-
-[@react.component]
-let make = (~minX=None, ~maxX=None, ~height=50, ~color=`hex("7e9db7")) =>
-
-
-
;
\ No newline at end of file
diff --git a/src/components/charts/DistPlusChart.re b/src/components/charts/DistPlusChart.re
index e6675bec..4f914699 100644
--- a/src/components/charts/DistPlusChart.re
+++ b/src/components/charts/DistPlusChart.re
@@ -1,6 +1,6 @@
module DistPlusChart = {
[@react.component]
- let make = (~distPlus: DistributionTypes.distPlus, ~onHover) => {
+ let make = (~distPlus: DistTypes.distPlus, ~onHover) => {
open Distributions.DistPlus;
let discrete = distPlus |> T.toDiscrete;
let continuous =
@@ -9,8 +9,8 @@ module DistPlusChart = {
|> E.O.fmap(Distributions.Continuous.getShape);
let minX = T.minX(distPlus);
let maxX = T.maxX(distPlus);
- let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
- DistTypes.DistributionUnit.toJson;
+ {
+ let make = (~distPlus: DistTypes.distPlus, ~onHover) => {
open Distributions.DistPlus;
let integral =
Distributions.DistPlus.T.Integral.get(~cache=None, distPlus);
@@ -35,8 +35,8 @@ module IntegralChart = {
|> E.O.fmap(Distributions.Continuous.getShape);
let minX = T.minX(integral);
let maxX = T.maxX(integral);
- let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
- DistTypes.DistributionUnit.toJson;
+ {
+let make = (~distPlus: DistTypes.distPlus) => {
let (x, setX) = React.useState(() => 0.);
let chart =
React.useMemo1(
diff --git a/src/components/charts/CdfChart__Plain.re b/src/components/charts/DistributionChart.re
similarity index 55%
rename from src/components/charts/CdfChart__Plain.re
rename to src/components/charts/DistributionChart.re
index 62c7a05b..b538f9bf 100644
--- a/src/components/charts/CdfChart__Plain.re
+++ b/src/components/charts/DistributionChart.re
@@ -1,3 +1,65 @@
+module RawChart = {
+ [@bs.module "./cdfChartReact.js"]
+ external cdfChart: ReasonReact.reactClass = "default";
+
+ type primaryDistribution =
+ option({
+ .
+ "xs": array(float),
+ "ys": array(float),
+ });
+
+ type discrete =
+ option({
+ .
+ "xs": array(float),
+ "ys": array(float),
+ });
+
+ [@react.component]
+ let make =
+ (
+ ~height=?,
+ ~marginBottom=?,
+ ~marginTop=?,
+ ~maxX=?,
+ ~minX=?,
+ ~onHover=(f: float) => (),
+ ~continuous=?,
+ ~discrete=?,
+ ~scale=?,
+ ~showDistributionLines=?,
+ ~showDistributionYAxis=?,
+ ~showVerticalLine=?,
+ ~timeScale=?,
+ ~verticalLine=?,
+ ~children=[||],
+ ) =>
+ ReasonReact.wrapJsForReason(
+ ~reactClass=cdfChart,
+ ~props=
+ makeProps(
+ ~height?,
+ ~marginBottom?,
+ ~marginTop?,
+ ~maxX?,
+ ~minX?,
+ ~onHover,
+ ~continuous?,
+ ~discrete?,
+ ~scale?,
+ ~showDistributionLines?,
+ ~showDistributionYAxis?,
+ ~showVerticalLine?,
+ ~timeScale?,
+ ~verticalLine?,
+ (),
+ ),
+ children,
+ )
+ |> ReasonReact.element;
+};
+
module Styles = {
open Css;
let textOverlay = style([position(`absolute)]);
@@ -40,7 +102,7 @@ let make =
~timeScale=?,
) => {
-
option(float);
let maxX: t => option(float);
let pointwiseFmap: (float => float, t) => t;
- let xToY: (float, t) => DistributionTypes.mixedPoint;
- let toShape: t => DistributionTypes.shape;
- let toContinuous: t => option(DistributionTypes.continuousShape);
- let toDiscrete: t => option(DistributionTypes.discreteShape);
- let toScaledContinuous: t => option(DistributionTypes.continuousShape);
- let toScaledDiscrete: t => option(DistributionTypes.discreteShape);
+ let xToY: (float, t) => DistTypes.mixedPoint;
+ let toShape: t => DistTypes.shape;
+ let toContinuous: t => option(DistTypes.continuousShape);
+ let toDiscrete: t => option(DistTypes.discreteShape);
+ let toScaledContinuous: t => option(DistTypes.continuousShape);
+ let toScaledDiscrete: t => option(DistTypes.discreteShape);
type integral;
let integral: (~cache: option(integral), t) => integral;
@@ -62,7 +62,7 @@ module Dist = (T: dist) => {
};
module Continuous = {
- type t = DistributionTypes.continuousShape;
+ type t = DistTypes.continuousShape;
let xyShape = (t: t) => t.xyShape;
let getShape = (t: t) => t.xyShape;
let interpolation = (t: t) => t.interpolation;
@@ -73,8 +73,7 @@ module Continuous = {
interpolation,
};
let oShapeMap =
- (fn, {xyShape, interpolation}: t)
- : option(DistributionTypes.continuousShape) =>
+ (fn, {xyShape, interpolation}: t): option(DistTypes.continuousShape) =>
fn(xyShape) |> E.O.fmap(xyShape => make(xyShape, interpolation));
let toLinear = (t: t): t =>
@@ -88,8 +87,8 @@ module Continuous = {
module T =
Dist({
- type t = DistributionTypes.continuousShape;
- type integral = DistributionTypes.continuousShape;
+ type t = DistTypes.continuousShape;
+ type integral = DistTypes.continuousShape;
let shapeFn = (fn, t: t) => t |> xyShape |> fn;
// TODO: Obviously fix this, it's terrible
let integral = (~cache, t) =>
@@ -108,11 +107,11 @@ module Continuous = {
let maxX = shapeFn(XYShape.maxX);
let pointwiseFmap = (fn, t: t) =>
t |> xyShape |> XYShape.pointwiseMap(fn) |> fromShape;
- let toShape = (t: t): DistributionTypes.shape => Continuous(t);
+ let toShape = (t: t): DistTypes.shape => Continuous(t);
// TODO: When Roman's PR comes in, fix this bit.
let xToY = (f, t) =>
shapeFn(CdfLibrary.Distribution.findY(f), t)
- |> DistributionTypes.MixedPoint.makeContinuous;
+ |> DistTypes.MixedPoint.makeContinuous;
let integralXtoY = (~cache, f, t) =>
t |> integral(~cache) |> shapeFn(CdfLibrary.Distribution.findY(f));
let toContinuous = t => Some(t);
@@ -125,8 +124,8 @@ module Continuous = {
module Discrete = {
module T =
Dist({
- type t = DistributionTypes.discreteShape;
- type integral = DistributionTypes.continuousShape;
+ type t = DistTypes.discreteShape;
+ type integral = DistTypes.continuousShape;
let integral = (~cache, t) =>
cache
|> E.O.default(
@@ -143,14 +142,14 @@ module Discrete = {
let minX = XYShape.minX;
let maxX = XYShape.maxX;
let pointwiseFmap = XYShape.pointwiseMap;
- let toShape = (t: t): DistributionTypes.shape => Discrete(t);
+ let toShape = (t: t): DistTypes.shape => Discrete(t);
let toContinuous = _ => None;
let toDiscrete = t => Some(t);
let toScaledContinuous = t => None;
let toScaledDiscrete = t => Some(t);
let xToY = (f, t) =>
CdfLibrary.Distribution.findY(f, t)
- |> DistributionTypes.MixedPoint.makeDiscrete;
+ |> DistTypes.MixedPoint.makeDiscrete;
let integralXtoY = (~cache, f, t) =>
t |> XYShape.accumulateYs |> CdfLibrary.Distribution.findY(f);
});
@@ -159,14 +158,13 @@ module Discrete = {
module Mixed = {
let make =
(~continuous, ~discrete, ~discreteProbabilityMassFraction)
- : DistributionTypes.mixedShape => {
+ : DistTypes.mixedShape => {
continuous,
discrete,
discreteProbabilityMassFraction,
};
- let clean =
- (t: DistributionTypes.mixedShape): option(DistributionTypes.shape) => {
+ let clean = (t: DistTypes.mixedShape): option(DistTypes.shape) => {
switch (t) {
| {
continuous: {xyShape: {xs: [||], ys: [||]}},
@@ -183,34 +181,34 @@ module Mixed = {
};
let scaleDiscreteFn =
- ({discreteProbabilityMassFraction}: DistributionTypes.mixedShape, f) =>
+ ({discreteProbabilityMassFraction}: DistTypes.mixedShape, f) =>
f *. discreteProbabilityMassFraction;
let scaleContinuousFn =
- ({discreteProbabilityMassFraction}: DistributionTypes.mixedShape, f) =>
+ ({discreteProbabilityMassFraction}: DistTypes.mixedShape, f) =>
f *. (1.0 -. discreteProbabilityMassFraction);
module T =
Dist({
- type t = DistributionTypes.mixedShape;
- type integral = DistributionTypes.continuousShape;
+ type t = DistTypes.mixedShape;
+ type integral = DistTypes.continuousShape;
let minX = ({continuous, discrete}: t) =>
min(Continuous.T.minX(continuous), Discrete.T.minX(discrete));
let maxX = ({continuous, discrete}: t) =>
max(Continuous.T.maxX(continuous), Discrete.T.maxX(discrete));
- let toShape = (t: t): DistributionTypes.shape => Mixed(t);
+ let toShape = (t: t): DistTypes.shape => Mixed(t);
let toContinuous = ({continuous}: t) => Some(continuous);
let toDiscrete = ({discrete}: t) => Some(discrete);
let xToY = (f, {discrete, continuous} as t: t) => {
let c =
continuous
|> Continuous.T.xToY(f)
- |> DistributionTypes.MixedPoint.fmap(scaleContinuousFn(t));
+ |> DistTypes.MixedPoint.fmap(scaleContinuousFn(t));
let d =
discrete
|> Discrete.T.xToY(f)
- |> DistributionTypes.MixedPoint.fmap(scaleDiscreteFn(t));
- DistributionTypes.MixedPoint.add(c, d);
+ |> DistTypes.MixedPoint.fmap(scaleDiscreteFn(t));
+ DistTypes.MixedPoint.add(c, d);
};
let scaleContinuous =
@@ -284,8 +282,8 @@ module Mixed = {
module Shape = {
module T =
Dist({
- type t = DistributionTypes.shape;
- type integral = DistributionTypes.continuousShape;
+ type t = DistTypes.shape;
+ type integral = DistTypes.continuousShape;
let mapToAll = (t: t, (fn1, fn2, fn3)) =>
switch (t) {
@@ -389,7 +387,7 @@ module Shape = {
};
module DistPlus = {
- open DistributionTypes;
+ open DistTypes;
let make =
(
~shape,
@@ -420,8 +418,8 @@ module DistPlus = {
module T =
Dist({
- type t = DistributionTypes.distPlus;
- type integral = DistributionTypes.distPlus;
+ type t = DistTypes.distPlus;
+ type integral = DistTypes.distPlus;
let toShape = ({shape, _}: t) => shape;
let shapeFn = (fn, t: t) => t |> toShape |> fn;
let toContinuous = shapeFn(Shape.T.toContinuous);
diff --git a/src/core/MixedShapeBuilder.re b/src/distributions/MixedShapeBuilder.re
similarity index 100%
rename from src/core/MixedShapeBuilder.re
rename to src/distributions/MixedShapeBuilder.re
diff --git a/src/core/TimeTypes.re b/src/distributions/TimeTypes.re
similarity index 100%
rename from src/core/TimeTypes.re
rename to src/distributions/TimeTypes.re
diff --git a/src/core/XYShape.re b/src/distributions/XYShape.re
similarity index 92%
rename from src/core/XYShape.re
rename to src/distributions/XYShape.re
index 8da043ca..531282d4 100644
--- a/src/core/XYShape.re
+++ b/src/distributions/XYShape.re
@@ -1,4 +1,4 @@
-open DistributionTypes;
+open DistTypes;
let _lastElement = (a: array('a)) =>
switch (Belt.Array.size(a)) {
| 0 => None
@@ -24,17 +24,17 @@ let fromArrays = (xs, ys): t => {xs, ys};
let pointwiseMap = (fn, t: t): t => {xs: t.xs, ys: t.ys |> E.A.fmap(fn)};
let intersperce = (t1: t, t2: t) => {
- let foo: ref(array((float, float))) = ref([||]);
+ let items: ref(array((float, float))) = ref([||]);
let t1 = zip(t1);
let t2 = zip(t2);
Belt.Array.forEachWithIndex(t1, (i, item) => {
switch (Belt.Array.get(t2, i)) {
- | Some(r) => foo := E.A.append(foo^, [|item, r|])
- | None => foo := E.A.append(foo^, [|item|])
+ | Some(r) => items := E.A.append(items^, [|item, r|])
+ | None => items := E.A.append(items^, [|item|])
}
});
- foo^ |> Belt.Array.unzip |> fromArray;
+ items^ |> Belt.Array.unzip |> fromArray;
};
let scaleCdfTo = (~scaleTo=1., t: t) =>
@@ -70,6 +70,9 @@ let _transverseShape = (fn, p: t) => {
let accumulateYs = _transverseShape((aCurrent, aLast) => aCurrent +. aLast);
let subtractYs = _transverseShape((aCurrent, aLast) => aCurrent -. aLast);
+let findY = CdfLibrary.Distribution.findY;
+let findX = CdfLibrary.Distribution.findX;
+
module Range = {
// ((lastX, lastY), (nextX, nextY))
type zippedRange = ((float, float), (float, float));
@@ -121,7 +124,4 @@ module Range = {
|> E.O.fmap(Belt.Array.unzip)
|> E.O.fmap(fromArray)
|> E.O.fmap(intersperce(t));
-};
-
-let findY = CdfLibrary.Distribution.findY;
-let findX = CdfLibrary.Distribution.findX;
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/src/interface/Prop.re b/src/interface/Prop.re
index 89971d8e..38a4519a 100644
--- a/src/interface/Prop.re
+++ b/src/interface/Prop.re
@@ -9,7 +9,7 @@ module Value = {
| DateTime(MomentRe.Moment.t)
| FloatPoint(float)
| Probability(float)
- | DistPlusIngredients(DistributionTypes.distPlusIngredients)
+ | DistPlusIngredients(DistTypes.distPlusIngredients)
| ConditionalArray(array(conditional))
| FloatCdf(string);
@@ -85,7 +85,7 @@ module ValueCluster = {
[ | `combination(range(MomentRe.Moment.t)) | `item(string)],
)
| Probability([ | `item(string)])
- | DistPlusIngredients([ | `item(DistributionTypes.distPlusIngredients)])
+ | DistPlusIngredients([ | `item(DistTypes.distPlusIngredients)])
| ConditionalArray([ | `item(array(conditional))])
| FloatCdf([ | `item(string)]);
};
diff --git a/src/lib/Chart.re b/src/lib/Chart.re
deleted file mode 100644
index 1935f039..00000000
--- a/src/lib/Chart.re
+++ /dev/null
@@ -1,42 +0,0 @@
-module Styles = {
- open Css;
- let graph = chartColor =>
- style([
- selector(".x-axis", [fontSize(`px(9))]),
- selector(".x-axis .domain", [display(`none)]),
- selector(".x-axis .tick line", [display(`none)]),
- selector(".x-axis .tick text", [color(`hex("bfcad4"))]),
- selector(".chart .area-path", [SVG.fill(chartColor)]),
- selector(".lollipops-line", [SVG.stroke(`hex("bfcad4"))]),
- selector(
- ".lollipops-circle",
- [SVG.stroke(`hex("bfcad4")), SVG.fill(`hex("bfcad4"))],
- ),
- selector(".lollipops-x-axis .domain", [display(`none)]),
- selector(".lollipops-x-axis .tick line", [display(`none)]),
- selector(".lollipops-x-axis .tick text", [display(`none)]),
- ]);
-};
-
-[@react.component]
-let make =
- (
- ~data,
- ~minX=None,
- ~maxX=None,
- ~width=300,
- ~height=50,
- ~color=`hex("7e9db7"),
- ) =>
-
-
-
;
\ No newline at end of file
diff --git a/src/utility/CdfLibrary.re b/src/utility/CdfLibrary.re
index aabbc092..586c7957 100644
--- a/src/utility/CdfLibrary.re
+++ b/src/utility/CdfLibrary.re
@@ -5,16 +5,14 @@ module JS = {
ys: array(float),
};
- let distToJs = (d: DistributionTypes.xyShape) =>
- distJs(~xs=d.xs, ~ys=d.ys);
+ let distToJs = (d: DistTypes.xyShape) => distJs(~xs=d.xs, ~ys=d.ys);
- let jsToDist = (d: distJs): DistributionTypes.xyShape => {
+ let jsToDist = (d: distJs): DistTypes.xyShape => {
xs: xsGet(d),
ys: ysGet(d),
};
- let doAsDist = (f, d: DistributionTypes.xyShape) =>
- d |> distToJs |> f |> jsToDist;
+ let doAsDist = (f, d: DistTypes.xyShape) => d |> distToJs |> f |> jsToDist;
[@bs.module "./CdfLibrary.js"]
external cdfToPdf: distJs => distJs = "cdfToPdf";
diff --git a/src/utility/Guesstimator.re b/src/utility/Guesstimator.re
index 1daddcf6..0122e80e 100644
--- a/src/utility/Guesstimator.re
+++ b/src/utility/Guesstimator.re
@@ -5,7 +5,7 @@ module Internals = {
ys: array(float),
};
- let jsToDistDiscrete = (d: discrete): DistributionTypes.discreteShape => {
+ let jsToDistDiscrete = (d: discrete): DistTypes.discreteShape => {
xs: xsGet(d),
ys: ysGet(d),
};
@@ -21,14 +21,14 @@ module Internals = {
|> CdfLibrary.JS.jsToDist
|> Distributions.Continuous.fromShape;
- let toDiscrete = (r: combined): DistributionTypes.xyShape =>
+ let toDiscrete = (r: combined): DistTypes.xyShape =>
discreteGet(r) |> jsToDistDiscrete;
[@bs.module "./GuesstimatorLibrary.js"]
external toCombinedFormat: (string, int) => combined = "run";
// todo: Format to correct mass, also normalize the pdf.
- let toMixedShape = (r: combined): option(DistributionTypes.mixedShape) => {
+ let toMixedShape = (r: combined): option(DistTypes.mixedShape) => {
let assumptions: MixedShapeBuilder.assumptions = {
continuous: ADDS_TO_1,
discrete: ADDS_TO_CORRECT_PROBABILITY,