fix: Attain parity with previous implementation

This is achieved by not adding more points in between i
the points are already pretty close
This commit is contained in:
NunoSempere 2022-05-11 12:56:56 -04:00
parent 599c14b32c
commit 5c9f57a24a
2 changed files with 18 additions and 12 deletions

View File

@ -11,7 +11,7 @@ module Epsilon = {
module Environment = { module Environment = {
let defaultXYPointLength = 1000 let defaultXYPointLength = 1000
let defaultSampleCount = 10000 let defaultSampleCount = 1000
let enrichmentFactor = 10 let enrichmentFactor = 10
} }

View File

@ -468,18 +468,24 @@ module PointwiseCombination = {
} }
let getInBetween = (x1: float, x2: float): array<float> => { let getInBetween = (x1: float, x2: float): array<float> => {
let newPointsArray = Belt.Array.makeBy(points - 1, i => i) switch x1 -. x2 > 2.0 *. MagicNumbers.Epsilon.seven {
// don't repeat the x2 point, it will be gotten in the next iteration. | false => [x1]
let result = Js.Array.mapi((pos, i) => | true => {
switch i { let newPointsArray = Belt.Array.makeBy(points - 1, i => i)
| 0 => x1 // don't repeat the x2 point, it will be gotten in the next iteration.
| _ => let result = Js.Array.mapi((pos, i) =>
x1 *. switch i {
(Belt.Float.fromInt(points) -. Belt.Float.fromInt(pos)) /. | 0 => x1
Belt.Float.fromInt(points) +. x2 *. Belt.Float.fromInt(pos) /. Belt.Float.fromInt(points) | _ =>
x1 *.
(Belt.Float.fromInt(points) -. Belt.Float.fromInt(pos)) /.
Belt.Float.fromInt(points) +.
x2 *. Belt.Float.fromInt(pos) /. Belt.Float.fromInt(points)
}
, newPointsArray)
result
} }
, newPointsArray) }
result
} }
let newXsUnflattened = Js.Array.mapi((x, i) => let newXsUnflattened = Js.Array.mapi((x, i) =>
switch i < length - 2 { switch i < length - 2 {