static LinkedHashMap<String, KiePMMLProbabilityConfidence> evaluateProbabilityConfidenceMap(final List<KiePMMLScoreDistribution> kiePMMLScoreDistributions,
                                                                                                final double missingValuePenalty) {
        LinkedHashMap<String, KiePMMLProbabilityConfidence> toReturn = new LinkedHashMap<>();
        if (kiePMMLScoreDistributions == null || kiePMMLScoreDistributions.isEmpty()) {
            return toReturn;
        }
        if (kiePMMLScoreDistributions.get(0).hasProbability()) {
            for (KiePMMLScoreDistribution kiePMMLScoreDistribution : kiePMMLScoreDistributions) {
                toReturn.put(kiePMMLScoreDistribution.getValue(), new KiePMMLProbabilityConfidence(kiePMMLScoreDistribution.getProbability(), kiePMMLScoreDistribution.getEvaluatedConfidence(missingValuePenalty)));
            }
        } else {
            int totalRecordCount = kiePMMLScoreDistributions.stream()
                    .map(KiePMMLScoreDistribution::getRecordCount)
                    .reduce(0, Integer::sum);
            for (KiePMMLScoreDistribution kiePMMLScoreDistribution : kiePMMLScoreDistributions) {
                toReturn.put(kiePMMLScoreDistribution.getValue(), new KiePMMLProbabilityConfidence(kiePMMLScoreDistribution.getEvaluatedProbability(totalRecordCount), kiePMMLScoreDistribution.getEvaluatedConfidence(missingValuePenalty)));
            }
        }
        return toReturn;
    }
@Test
    void evaluateProbabilityConfidenceMap() {
        List<KiePMMLScoreDistribution> kiePMMLScoreDistributions = getRandomKiePMMLScoreDistributions(false);
        int totalRecordCount = kiePMMLScoreDistributions.stream()
                .map(KiePMMLScoreDistribution::getRecordCount)
                .reduce(0, Integer::sum);
        final double missingValuePenalty = (double) new Random().nextInt(100) / 10;
        LinkedHashMap<String, KiePMMLProbabilityConfidence> retrievedNoProbability = KiePMMLNode.getProbabilityConfidenceMap(kiePMMLScoreDistributions, missingValuePenalty);
        assertThat(retrievedNoProbability).isNotNull();
        kiePMMLScoreDistributions.forEach(kiePMMLScoreDistribution -> {
            assertThat(retrievedNoProbability).containsKey(kiePMMLScoreDistribution.getValue());
            KiePMMLProbabilityConfidence kiePMMLProbabilityConfidence = retrievedNoProbability.get(kiePMMLScoreDistribution.getValue());
            assertThat(kiePMMLProbabilityConfidence).isNotNull();
            double probabilityExpected = (double) kiePMMLScoreDistribution.getRecordCount() / (double) totalRecordCount;
            double confidenceExpected = kiePMMLScoreDistribution.getConfidence() * missingValuePenalty;
            assertThat(kiePMMLProbabilityConfidence.getProbability()).isCloseTo(probabilityExpected, Offset.offset(0.000000001));
            assertThat(kiePMMLProbabilityConfidence.getConfidence()).isCloseTo(confidenceExpected, Offset.offset(0.000000001));
        });
        //
        kiePMMLScoreDistributions = getRandomKiePMMLScoreDistributions(true);
        LinkedHashMap<String, KiePMMLProbabilityConfidence> retrievedProbability = KiePMMLNode.getProbabilityConfidenceMap(kiePMMLScoreDistributions, missingValuePenalty);
        assertThat(retrievedNoProbability).isNotNull();
        kiePMMLScoreDistributions.forEach(kiePMMLScoreDistribution -> {
            assertThat(retrievedProbability).containsKey(kiePMMLScoreDistribution.getValue());
            KiePMMLProbabilityConfidence kiePMMLProbabilityConfidence = retrievedProbability.get(kiePMMLScoreDistribution.getValue());
            assertThat(kiePMMLProbabilityConfidence).isNotNull();
            double probabilityExpected = kiePMMLScoreDistribution.getProbability();
            double confidenceExpected = kiePMMLScoreDistribution.getConfidence() * missingValuePenalty;
            assertThat(kiePMMLProbabilityConfidence.getProbability()).isCloseTo(probabilityExpected, Offset.offset(0.000000001));
            assertThat(kiePMMLProbabilityConfidence.getConfidence()).isCloseTo(confidenceExpected, Offset.offset(0.000000001));
        });
    }