Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c554070

Browse files
committed
fixup silverman valu fallback
.. this time to "really" make the transition smooth
1 parent 36cc37d commit c554070

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/traces/violin/calc.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,7 @@ function silvermanRule(len, ssd, iqr) {
8181
}
8282

8383
function calcBandwidth(trace, cdi, vals) {
84-
var bw;
85-
86-
if(trace.bandwidth) {
87-
bw = trace.bandwidth;
88-
} else {
89-
var len = vals.length;
90-
var ssd = Lib.stdev(vals, len - 1, cdi.mean);
91-
bw = silvermanRule(len, ssd, cdi.q3 - cdi.q1);
92-
}
84+
var span = cdi.max - cdi.min;
9385

9486
// Limit how small the bandwidth can be.
9587
//
@@ -98,9 +90,17 @@ function calcBandwidth(trace, cdi, vals) {
9890
// of the distribution.
9991
// We also want to limit custom bandwidths
10092
// to not blow up kde computations.
101-
return ((cdi.max - cdi.min) / bw) < 1e5 ?
102-
bw :
103-
(cdi.max - cdi.min) / 100;
93+
94+
if(trace.bandwidth) {
95+
return Math.max(trace.bandwidth, span / 1e4);
96+
} else {
97+
var len = vals.length;
98+
var ssd = Lib.stdev(vals, len - 1, cdi.mean);
99+
return Math.max(
100+
silvermanRule(len, ssd, cdi.q3 - cdi.q1),
101+
span / 100
102+
);
103+
}
104104
}
105105

106106
function calcSpan(trace, cdi, valAxis, bandwidth) {
-694 Bytes
Loading

0 commit comments

Comments
 (0)