Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
result: function() {
if (vals.length === 0) {
return null;
}
var edf = new Digest();
for (var i = vals.length - 1 ; i >= 0 ; i--) {
edf.push(vals.get(i));
}
var median = edf.percentile(0.5);
var ad_edf = new Digest();
for (i = vals.length - 1 ; i >= 0 ; i--) {
ad_edf.push(Math.abs(vals.get(i) - median));
}
return ad_edf.percentile(0.5);
},
expire: function(pt) {
fn: function(field, pct) {
var data = new Digest();
pct = (pct || 0.50) ;
return {
result: function() {
if (data.size() === 0) {
return null;
}
return data.percentile(pct);
},
update: function(pt) {
if (pt[field] !== undefined) {
values.ensureNumber(pt[field], 'percentile expects numeric fields, but received: '+values.toString(pt[field]));
data.push(pt[field]);
}
}
};
}
result: function() {
if (vals.length === 0) {
return null;
}
var edf = new Digest();
for (var i = vals.length - 1 ; i >= 0 ; i--) {
edf.push(vals.get(i));
}
var median = edf.percentile(0.5);
var ad_edf = new Digest();
for (i = vals.length - 1 ; i >= 0 ; i--) {
ad_edf.push(Math.abs(vals.get(i) - median));
}
return ad_edf.percentile(0.5);
},
expire: function(pt) {