@@ -0,0 +1,2065 @@
+/*%0A * Copyright (c) 2013 - 2017 xxyy (Philipp Nowak; xyc@l1t.li). All rights reserved.%0A *%0A * Any usage, including, but not limited to, compiling, running, redistributing, printing,%0A *  copying and reverse-engineering is strictly prohibited without explicit written permission%0A *  from the original author and may result in legal steps being taken.%0A *%0A * See the included LICENSE file (core/src/main/resources) for details.%0A */%0A%0Aimport li.l1t.common.util.math.WeightedDistribution;%0A%0Aimport java.security.SecureRandom;%0Aimport java.text.MessageFormat;%0Aimport java.util.*;%0Aimport java.util.function.Function;%0Aimport java.util.stream.Collectors;%0Aimport java.util.stream.IntStream;%0Aimport java.util.stream.Stream;%0A%0Apublic class WeightedDistributionProbabilityTestScratch %7B%0A    public static void main (String... args) %7B%0A        WeightedDistribution%3CInteger%3E dist = new WeightedDistribution%3C%3E();%0A        SecureRandom random = new SecureRandom();%0A        IntStream.range(0, 15)%0A                .forEach(lel -%3E dist.put(lel, 1));%0A        IntStream.range(16, 20)%0A                .forEach(lel -%3E dist.put(lel, 5));%0A        Stream.generate(() -%3E dist.next(random))%0A                .limit(5_000_000)%0A                .collect(Collectors.groupingBy(Function.identity()))%0A                .entrySet().stream()%0A                .map(e -%3E MessageFormat.format(%22 -%3E %7B0%7D = %7B1%7D%25 %5E %7B2%7D%22, e.getKey(), (%0A                        (double) e.getValue().size() / 5_000_000D) * 100D, expectedProbability(dist, e)))%0A                .forEach(System.out::println);%0A    %7D%0A%0A    private static double expectedProbability(WeightedDistribution%3CInteger%3E dist, Map.Entry%3CInteger, List%3CInteger%3E%3E e) %7B%0A        double prob = dist.probabilities().entrySet().stream()%0A                .filter(e2 -%3E e2.getValue().equals(e.getKey()))%0A                .mapToDouble(Map.Entry::getKey)%0A                .findFirst().orElseThrow(AssertionError::new);%0A        Double lowerKey = Optional.ofNullable(dist.probabilities().lowerKey(prob)).orElse(0D);%0A        return ((prob - lowerKey) / dist.probabilitySum()) * 100;%0A    %7D%0A%7D

Add scratch file that shows how accurate WeightedDistribution is