/** * Adds a sample to a histogram. * * @param x The value to add. */ @Override public void add(double x) { add(x, 1); }
@Override public void add(TDigest other) { List<Centroid> tmp = new ArrayList<>(); for (Centroid centroid : other.centroids()) { tmp.add(centroid); } Collections.shuffle(tmp, gen); for (Centroid centroid : tmp) { add(centroid.mean(), centroid.count(), centroid); } }
/** * Adds a sample to a histogram. * * @param x The value to add. */ @Override public void add(double x) { add(x, 1); }
@Override public void add(TDigest other) { List<Centroid> tmp = new ArrayList<Centroid>(); for (Centroid centroid : other.centroids()) { tmp.add(centroid); } Collections.shuffle(tmp, gen); for (Centroid centroid : tmp) { add(centroid.mean(), centroid.count(), centroid); } }
protected static TDigest merge(Iterable<TDigest> subData, Random gen, TDigest r) { List<Centroid> centroids = new ArrayList<Centroid>(); boolean recordAll = false; for (TDigest digest : subData) { for (Centroid centroid : digest.centroids()) { centroids.add(centroid); } recordAll |= digest.isRecording(); } Collections.shuffle(centroids, gen); if (recordAll) { r.recordAllData(); } for (Centroid c : centroids) { if (r.isRecording()) { // TODO should do something better here. } ((AbstractTDigest) r).add(c.mean(), c.count(), c); } return r; }