From 6306fa9ca25242c2cf7ea1ae60e05bfa029cfd9c Mon Sep 17 00:00:00 2001 From: Sebastian Kosch Date: Wed, 3 Jun 2020 09:24:55 -0700 Subject: [PATCH] Clean up interpolateXs function --- src/distPlus/symbolic/SymbolicDist.re | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/distPlus/symbolic/SymbolicDist.re b/src/distPlus/symbolic/SymbolicDist.re index ada4e2c0..d867eb22 100644 --- a/src/distPlus/symbolic/SymbolicDist.re +++ b/src/distPlus/symbolic/SymbolicDist.re @@ -268,18 +268,16 @@ module GenericSimple = { let interpolateXs = (~xSelection: [ | `Linear | `ByWeight]=`Linear, dist: dist, sampleCount) => { - switch (xSelection) { - | `Linear => E.A.Floats.range(min(dist), max(dist), sampleCount) - | `ByWeight => - switch (dist) { + switch (xSelection, dist) { + | (`Linear, _) => E.A.Floats.range(min(dist), max(dist), sampleCount) + | (`ByWeight, `Uniform(n)) => // In `ByWeight mode, uniform distributions get special treatment because we need two x's // on either side for proper rendering (just left and right of the discontinuities). - | `Uniform(n) => E.A.of_list([n.low -. minCdfValue, n.low +. minCdfValue, - n.high -. minCdfValue, n.high +. minCdfValue]) - | dist => - let ys = E.A.Floats.range(minCdfValue, maxCdfValue, sampleCount) - ys |> E.A.fmap(y => inv(y, dist)) - } + let dx = 0.00001 *. (n.high -. n.low); + [|n.low -. dx, n.low +. dx, n.high -. dx, n.high +. dx|] + | (`ByWeight, _) => + let ys = E.A.Floats.range(minCdfValue, maxCdfValue, sampleCount) + ys |> E.A.fmap(y => inv(y, dist)) }; };