protected Centroid createCentroid(double mean, int id) { return new Centroid(mean, id, recordAllData); } }
public static Centroid createWeighted(double x, int w, Iterable<? extends Double> data) { Centroid r = new Centroid(data != null); r.add(x, w, data); return r; }
@Override public Centroid next() { final Centroid next = new Centroid(mean(nextNode), count(nextNode)); final List<Double> data = data(nextNode); if (data != null) { for (Double x : data) { next.insertData(x); } } nextNode = tree.next(nextNode); return next; }
protected Centroid createCentroid(double mean, int id) { return new Centroid(mean, id, recordAllData); } }
public static Centroid createWeighted(double x, int w, Iterable<? extends Double> data) { Centroid r = new Centroid(data != null); r.add(x, w, data); return r; }
/** * Not clear to me that this is a good idea, maybe just add the temp points and existing centroids rather then merging * first? */ @Override public Collection<Centroid> centroids() { // we don't actually keep centroid structures around so we have to fake it List<Centroid> r = new ArrayList<>(); int count = centroidCount(); for (int i = 0; i < count; i++) { r.add(new Centroid(mean[i], (int) weight[i], data != null ? data.get(i) : null)); } return r; }
/** * Not clear to me that this is a good idea, maybe just add the temp points and existing centroids rather then merging * first? */ @Override public Collection<Centroid> centroids() { // we don't actually keep centroid structures around so we have to fake it List<Centroid> r = new ArrayList<>(); int count = centroidCount(); for (int i = 0; i < count; i++) { r.add(new Centroid(mean[i], (int) weight[i], data != null ? data.get(i) : null)); } return r; }
@Override public Iterable<? extends Centroid> centroids() { List<Centroid> r = new ArrayList<Centroid>(); Iterator<Index> ix = iterator(0, 0); while (ix.hasNext()) { Index index = ix.next(); Page current = data.get(index.page); Centroid centroid = new Centroid(current.centroids[index.subPage], current.counts[index.subPage]); if (current.history != null) { for (double x : current.history.get(index.subPage)) { centroid.insertData(x); } } r.add(centroid); } return r; }
public double max() { //This is a lie if the winning centroid's weight > 1 return perThreadHistogramBins.values().stream().flatMap(List::stream).map(b -> b.dist.centroids()). mapToDouble(cs -> getLast(cs, new Centroid(MIN_VALUE)).mean()).max().orElse(NaN); }
public double min() { // This is a lie if the winning centroid's weight > 1 return perThreadHistogramBins.values().stream().flatMap(List::stream).map(b -> b.dist.centroids()). mapToDouble(cs -> getFirst(cs, new Centroid(MAX_VALUE)).mean()).min().orElse(NaN); }
public double max() { //This is a lie if the winning centroid's weight > 1 return perThreadHistogramBins.values().stream().flatMap(List::stream).map(b -> b.dist.centroids()). mapToDouble(cs -> getLast(cs, new Centroid(MIN_VALUE)).mean()).max().orElse(NaN); }
public double min() { // This is a lie if the winning centroid's weight > 1 return perThreadHistogramBins.values().stream().flatMap(List::stream).map(b -> b.dist.centroids()). mapToDouble(cs -> getFirst(cs, new Centroid(MAX_VALUE)).mean()).min().orElse(NaN); }
Centroid end = new Centroid(0, 0, -1); Centroid next = null;
@Override public Centroid next() { final Centroid next = new Centroid(mean(nextNode), count(nextNode)); final List<Double> data = data(nextNode); if (data != null) { for (Double x : data) { next.insertData(x); } } nextNode = tree.next(nextNode); return next; }