Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('reports undefined when given no points', function(){
var tdigest = new TDigest();
var p = [0, 0.5, 1.0];
assert.deepEqual(tdigest.percentile(0.5), undefined);
assert.deepEqual(tdigest.percentile(p), [undefined,undefined,undefined]);
});
it('from a single point', function(){
it('preserves a discrete distribution', function(){
var digest = new Digest();
var i, ntimes = 1000, nvals=100;
for (i = 0 ; i < ntimes ; i++) {
for (j = 0 ; j < nvals ; j++) {
digest.push(j);
}
}
var result = digest.toArray();
for (i = 0 ; i < nvals ; i++) {
assert.deepEqual(result[i], {mean:i, n:ntimes});
}
});
it('compresses a continuous distribution', function(){
it('consumes nonnumeric points', function(){
var tdigest = new TDigest(false);
tdigest.push("foo");
tdigest.push("bar");
tdigest.push("baz");
tdigest.push("foo");
tdigest.push("freen");
tdigest.push("bork");
tdigest.push("bork");
tdigest.push("bork");
tdigest.push("books");
var points = tdigest.toArray();
assert.deepEqual(points, [
{mean:"bar", n:1},
{mean:"baz", n:1},
{mean:"books", n:1},
{mean:"bork", n:3},
{mean:"foo", n:2},
{mean:"freen", n:1},
]);
});
it('consumes same-valued points into a single point', function(){