/** * Create a new histogram, after applying the function on each of the event * counters. */ public Histogram modifyEventCounters(BiFunction<Range, Double, Double> fn) { return new Histogram(stream() .map(entry -> { entry.setCount(fn.apply(entry.getRange(), entry.getCount())); return entry; })); }
/** * Create a new histogram, after applying the function on each of the event * counters. */ public Histogram modifyEventCounters(BiFunction<Range, Double, Double> fn) { return new Histogram(stream() .map(entry -> { entry.setCount(fn.apply(entry.getRange(), entry.getCount())); return entry; })); }
/** * Subtracts two histograms. * * @throws IllegalArgumentException If the result contains mixed signs. */ public static Histogram subtract(Histogram x, Histogram y) { return new Histogram(Stream.concat( x.stream(), y.stream().map(rwc -> { rwc.setCount(-rwc.getCount()); return rwc; }))); }
succ.setCount(succ.getCount() + head.getCount()); continue; final double succ_right_fraction = 1 - succ_left_fraction; head.setCount(head.getCount() + succ_left_fraction * succ.getCount()); succ.setCount(succ_right_fraction * succ.getCount()); succ.setRange(new Range(mid, ceil)); imed.add(0, head); imed.add(0, new RangeWithCount(new Range(floor, ceil), head_left_fraction * head.getCount())); head.setRange(new Range(ceil, head.getRange().getCeil())); head.setCount(head_right_fraction * head.getCount()); sort(imed, cmp); result.remove(i); succ.setRange(new Range(pred.getRange().getFloor(), succ.getRange().getCeil())); succ.setCount(succ.getCount() + pred.getCount()); } else { ++i;
succ.setCount(succ.getCount() + head.getCount()); continue; final double succ_right_fraction = 1 - succ_left_fraction; head.setCount(head.getCount() + succ_left_fraction * succ.getCount()); succ.setCount(succ_right_fraction * succ.getCount()); succ.setRange(new Range(mid, ceil)); imed.add(0, head); imed.add(0, new RangeWithCount(new Range(floor, ceil), head_left_fraction * head.getCount())); head.setRange(new Range(ceil, head.getRange().getCeil())); head.setCount(head_right_fraction * head.getCount()); sort(imed, cmp); result.remove(i); succ.setRange(new Range(pred.getRange().getFloor(), succ.getRange().getCeil())); succ.setCount(succ.getCount() + pred.getCount()); } else { ++i;
/** * Subtracts two histograms. * * @throws IllegalArgumentException If the result contains mixed signs. */ public static Histogram subtract(Histogram x, Histogram y) { return new Histogram(Stream.concat( x.stream(), y.stream().map(rwc -> { rwc.setCount(-rwc.getCount()); return rwc; }))); }