We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4508c3f commit 262976eCopy full SHA for 262976e
function/smooth/17-smooth.js
@@ -54,6 +54,16 @@ module.exports = function(RED) {
54
v[top].tot = v[top].tot + n - v[top].pop;
55
value = v[top].tot / v[top].a.length;
56
}
57
+ if (node.action === "median") {
58
+ var sortedForMedian = v[top].a.slice().sort((a, b) => a - b);
59
+ var medianIndex = Math.floor(v[top].count / 2);
60
+ if (v[top].count % 2 === 0) {
61
+ value = (v[top].sortedForMedian[v[top].medianIndex - 1] + v[top].sortedForMedian[v[top].medianIndex]) / 2;
62
+ }
63
+ else {
64
+ value = v[top].sortedForMedian[v[top].medianIndex]
65
66
+
67
if (node.action === "sd") {
68
69
v[top].tot2 = v[top].tot2 + (n*n) - (v[top].pop * v[top].pop);
0 commit comments