How to use tdigest - 3 common examples

To help you get started, we’ve selected a few tdigest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github juttle / juttle / lib / runtime / reducers.js View on Github external
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) {
github juttle / juttle / lib / runtime / reducers.js View on Github external
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]);
                }
            }
        };
    }
github juttle / juttle / lib / runtime / reducers.js View on Github external
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) {

tdigest

javascript implementation of Dunning's T-Digest for streaming quantile approximation

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular tdigest functions