Realistic x selection for uniform distribution rendering
This commit is contained in:
parent
bd63a5f920
commit
f3f1861ba6
|
@ -255,13 +255,31 @@ module GenericSimple = {
|
||||||
| `Uniform({high}) => high
|
| `Uniform({high}) => high
|
||||||
| `Float(n) => n;
|
| `Float(n) => n;
|
||||||
|
|
||||||
|
|
||||||
|
/* This function returns a list of x's at which to evaluate the overall distribution (for rendering).
|
||||||
|
This function is called separately for each individual distribution.
|
||||||
|
|
||||||
|
When called with xSelection=`Linear, this function will return (sampleCount) x's, evenly
|
||||||
|
distributed between the min and max of the distribution (whatever those are defined to be above).
|
||||||
|
|
||||||
|
When called with xSelection=`ByWeight, this function will distribute the x's such as to
|
||||||
|
match the cumulative shape of the distribution. This is slower but may give better results.
|
||||||
|
*/
|
||||||
let interpolateXs =
|
let interpolateXs =
|
||||||
(~xSelection: [ | `Linear | `ByWeight]=`Linear, dist: dist, sampleCount) => {
|
(~xSelection: [ | `Linear | `ByWeight]=`Linear, dist: dist, sampleCount) => {
|
||||||
|
|
||||||
switch (xSelection) {
|
switch (xSelection) {
|
||||||
| `Linear => E.A.Floats.range(min(dist), max(dist), sampleCount)
|
| `Linear => E.A.Floats.range(min(dist), max(dist), sampleCount)
|
||||||
| `ByWeight =>
|
| `ByWeight =>
|
||||||
E.A.Floats.range(minCdfValue, maxCdfValue, sampleCount)
|
switch (dist) {
|
||||||
|> E.A.fmap(x => inv(x, dist))
|
// 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))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2491,7 +2491,7 @@ bs-moment@0.4.5, bs-moment@^0.4.4:
|
||||||
resolved "https://registry.yarnpkg.com/bs-moment/-/bs-moment-0.4.5.tgz#3f84fed55c2a70d25b0b6025e4e8d821fcdd4dc8"
|
resolved "https://registry.yarnpkg.com/bs-moment/-/bs-moment-0.4.5.tgz#3f84fed55c2a70d25b0b6025e4e8d821fcdd4dc8"
|
||||||
integrity sha512-anPYkFSof+X8EeomnP0fbQBvWFJeganwPqqARVB+fcdKYX2Uog/n3CCiFGEA+66yHbwnWZD5YFhtHCuyLMcQfQ==
|
integrity sha512-anPYkFSof+X8EeomnP0fbQBvWFJeganwPqqARVB+fcdKYX2Uog/n3CCiFGEA+66yHbwnWZD5YFhtHCuyLMcQfQ==
|
||||||
|
|
||||||
bs-platform@7.2.2, bs-platform@^7.2.2:
|
bs-platform@7.2.2:
|
||||||
version "7.2.2"
|
version "7.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-7.2.2.tgz#76fdc63e4889458ae3d257a0132107a792f2309c"
|
resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-7.2.2.tgz#76fdc63e4889458ae3d257a0132107a792f2309c"
|
||||||
integrity sha512-PWcFfN+jCTtT/rMaHDhKh+W9RUTpaRunmSF9vbLYcrJbpgCNW6aFKAY33u0P3mLxwuhshN3b4FxqGUBPj6exZQ==
|
integrity sha512-PWcFfN+jCTtT/rMaHDhKh+W9RUTpaRunmSF9vbLYcrJbpgCNW6aFKAY33u0P3mLxwuhshN3b4FxqGUBPj6exZQ==
|
||||||
|
|
Loading…
Reference in New Issue
Block a user