Auto-kernel-width
This commit is contained in:
parent
5ad426f4a9
commit
145452d50f
|
@ -60,8 +60,8 @@
|
||||||
"react-use": "^13.27.0",
|
"react-use": "^13.27.0",
|
||||||
"reason-react": ">=0.7.0",
|
"reason-react": ">=0.7.0",
|
||||||
"reschema": "1.3.0",
|
"reschema": "1.3.0",
|
||||||
"tailwindcss": "1.2.0",
|
"science": "^1.9.3",
|
||||||
"science": "1.9.3"
|
"tailwindcss": "1.2.0"
|
||||||
},
|
},
|
||||||
"alias": {
|
"alias": {
|
||||||
"react": "./node_modules/react",
|
"react": "./node_modules/react",
|
||||||
|
|
|
@ -88,6 +88,15 @@ module T = {
|
||||||
(continuous, discrete);
|
(continuous, discrete);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let kde = (~samples, ~outputXYPoints) => {
|
||||||
|
let width = Science.nrd0(samples);
|
||||||
|
let xyPointRange = E.A.Sorted.range(samples) |> E.O.default(0.0);
|
||||||
|
let xyPointWidth = xyPointRange /. float_of_int(outputXYPoints);
|
||||||
|
let kernelWidth = int_of_float(Jstat.max([|(width /. xyPointWidth), 1.0 |]));
|
||||||
|
Js.log4(samples, width, xyPointWidth, kernelWidth);
|
||||||
|
KDE.normalSampling(samples, outputXYPoints, kernelWidth);
|
||||||
|
};
|
||||||
|
|
||||||
// todo: Figure out some way of doing this without having to integrate so many times.
|
// todo: Figure out some way of doing this without having to integrate so many times.
|
||||||
let toShape = (~samples: t, ~outputXYPoints=3000, ~kernelWidth=10, ()) => {
|
let toShape = (~samples: t, ~outputXYPoints=3000, ~kernelWidth=10, ()) => {
|
||||||
Array.fast_sort(compare, samples);
|
Array.fast_sort(compare, samples);
|
||||||
|
@ -102,7 +111,7 @@ module T = {
|
||||||
let pdf: DistTypes.xyShape =
|
let pdf: DistTypes.xyShape =
|
||||||
continuousPart |> E.A.length > 5
|
continuousPart |> E.A.length > 5
|
||||||
? {
|
? {
|
||||||
continuousPart |> KDE.normalSampling(_, outputXYPoints, kernelWidth);
|
continuousPart |> kde(~samples=_, ~outputXYPoints)
|
||||||
}
|
}
|
||||||
: {xs: [||], ys: [||]};
|
: {xs: [||], ys: [||]};
|
||||||
let continuous = pdf |> Distributions.Continuous.make(`Linear);
|
let continuous = pdf |> Distributions.Continuous.make(`Linear);
|
||||||
|
|
|
@ -8579,7 +8579,7 @@ scheduler@^0.19.0:
|
||||||
loose-envify "^1.1.0"
|
loose-envify "^1.1.0"
|
||||||
object-assign "^4.1.1"
|
object-assign "^4.1.1"
|
||||||
|
|
||||||
science@1.9.3:
|
science@^1.9.3:
|
||||||
version "1.9.3"
|
version "1.9.3"
|
||||||
resolved "https://registry.yarnpkg.com/science/-/science-1.9.3.tgz#ec89bac44aeff2e5a2d749aa496f377089903dd4"
|
resolved "https://registry.yarnpkg.com/science/-/science-1.9.3.tgz#ec89bac44aeff2e5a2d749aa496f377089903dd4"
|
||||||
integrity sha1-7Im6xErv8uWi10mqSW83cImQPdQ=
|
integrity sha1-7Im6xErv8uWi10mqSW83cImQPdQ=
|
||||||
|
|
Loading…
Reference in New Issue
Block a user