Clean up interpolateXs function
This commit is contained in:
parent
68efbf0396
commit
6306fa9ca2
|
@ -268,18 +268,16 @@ module GenericSimple = {
|
||||||
let interpolateXs =
|
let interpolateXs =
|
||||||
(~xSelection: [ | `Linear | `ByWeight]=`Linear, dist: dist, sampleCount) => {
|
(~xSelection: [ | `Linear | `ByWeight]=`Linear, dist: dist, sampleCount) => {
|
||||||
|
|
||||||
switch (xSelection) {
|
switch (xSelection, dist) {
|
||||||
| `Linear => E.A.Floats.range(min(dist), max(dist), sampleCount)
|
| (`Linear, _) => E.A.Floats.range(min(dist), max(dist), sampleCount)
|
||||||
| `ByWeight =>
|
| (`ByWeight, `Uniform(n)) =>
|
||||||
switch (dist) {
|
|
||||||
// In `ByWeight mode, uniform distributions get special treatment because we need two x's
|
// 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).
|
// 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,
|
let dx = 0.00001 *. (n.high -. n.low);
|
||||||
n.high -. minCdfValue, n.high +. minCdfValue])
|
[|n.low -. dx, n.low +. dx, n.high -. dx, n.high +. dx|]
|
||||||
| dist =>
|
| (`ByWeight, _) =>
|
||||||
let ys = E.A.Floats.range(minCdfValue, maxCdfValue, sampleCount)
|
let ys = E.A.Floats.range(minCdfValue, maxCdfValue, sampleCount)
|
||||||
ys |> E.A.fmap(y => inv(y, dist))
|
ys |> E.A.fmap(y => inv(y, dist))
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user