static void getStats(List<Element<Double>> list, List<DoublePair> stats) {
		if (list.size() == 0) {
			return;
		}
		double totalWeight = list.get(0).element;
		double lastValue = list.get(0).weight;
		for (int i = 1; i < list.size(); i++) {
			Element<Double> element = list.get(i);
			double value = element.weight;
			double weight = element.element;
			if (value != lastValue) {
				stats.add(new DoublePair(lastValue, totalWeight));
				lastValue = value;
				totalWeight = weight;
			} else {
				totalWeight += weight;
			}
		}
		stats.add(new DoublePair(lastValue, totalWeight));
	}