Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how merge centroid? #8

Open
maodouchen opened this issue Nov 5, 2018 · 2 comments
Open

how merge centroid? #8

maodouchen opened this issue Nov 5, 2018 · 2 comments

Comments

@maodouchen
Copy link

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
Copy link
Owner

welch commented Nov 5, 2018

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
Copy link
Author

maodouchen commented Nov 5, 2018

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants