welch / tdigest

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

how merge centroid? #8

Open maodouchen opened 6 years ago

maodouchen commented 6 years ago

var a = [1,2,3,4,5] var b = [7,8,9,10]

var t1 = new TDigest() t1.push(a); var c1 = t1.toArray();

var t2 = new TDigest(); t2.push(b) var c2 = t2.toArray()

var t = new TDigest(); t.push(c1); t.push(c2);

t.summary()

i want merge centroids. Am i right?

welch commented 6 years ago

not the use case I envisioned. What do you mean by "am i right"? (and what do you imagine is the right answer here?)

maodouchen commented 6 years ago

for example:

var TDigest = require('tdigest').TDigest; var a = [1,2,3]; var t1 = new TDigest(); t1.push(a); var c1 = t1.toArray(); // centroid1 collections

var b = [4,5,5] var t2 = new TDigest(); t2.push(b); var c2 = t2.toArray(); // centroid2 collections

var t = new TDigest(); c1.forEach((centroid) => { const {mean, weight} = centroid; t.push(mean, weight) }) c2.forEach((centroid) => { const {mean, weight} = centroid; t.push(mean, weight) })

t.percentile(0.8)

can i get 80% percentile of a.concat(b) [1,2,3,4,5,5]