welch / tdigest

tdigest: javascript implementation of Dunning's T-Digest for streaming quantile approximation
MIT License
68 stars 10 forks source link

when calculate centroid, fixed number #9

Open maodouchen opened 5 years ago

maodouchen commented 5 years ago

TDigest.prototype._addweight = function(nearest, x, n) { // add weight at location x to nearest centroid. adding x to // nearest will not shift its relative position in the tree and // require reinsertion. // if (x !== nearest.mean) { nearest.mean += n * (x - nearest.mean) / (nearest.n + n); nearest.mean = nearest.mean.toFixed(number) // add this line? } nearest.cumn += n; nearest.mean_cumn += n / 2; nearest.n += n; this.n += n; };