Example usage for org.apache.commons.lang ArrayUtils EMPTY_DOUBLE_ARRAY

List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_DOUBLE_ARRAY

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils EMPTY_DOUBLE_ARRAY.

Prototype

null EMPTY_DOUBLE_ARRAY

To view the source code for org.apache.commons.lang ArrayUtils EMPTY_DOUBLE_ARRAY.

Click Source Link

Document

An empty immutable double array.

Usage

From source file:com.opengamma.analytics.financial.var.parametric.ParametricVaRDataBundleTest.java

@Test(expectedExceptions = IllegalArgumentException.class)
public void testWrongMatrixDimension() {
    final Matrix<double[]> m = new Matrix<double[]>() {

        @Override/*from   www. ja  v a 2 s .  c  o  m*/
        public int getNumberOfElements() {
            return 0;
        }

        @Override
        public double[] getEntry(final int... indices) {
            return ArrayUtils.EMPTY_DOUBLE_ARRAY;
        }

    };
    new ParametricVaRDataBundle(m, COV, ORDER);
}

From source file:com.opengamma.financial.analytics.model.YieldCurveNodeSensitivitiesHelper.java

public static Set<ComputedValue> getTimeLabelledSensitivitiesForCurve(final List<DoublesPair> resultList,
        final ValueSpecification resultSpec) {
    final int n = resultList.size();
    final Double[] keys = new Double[n];
    final double[] values = new double[n];
    final Object[] labels = new Object[n];
    LabelledMatrix1D<Double, Double> labelledMatrix = new DoubleLabelledMatrix1D(
            ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY, ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.EMPTY_DOUBLE_ARRAY);
    for (int i = 0; i < n; i++) {
        final DoublesPair pair = resultList.get(i);
        keys[i] = pair.first;/*from   ww  w . jav a2  s .  c  om*/
        values[i] = pair.second;
        labels[i] = s_formatter.format(pair.first);
        labelledMatrix = labelledMatrix.add(pair.first, s_formatter.format(pair.first), pair.second, 1e-16);
    }
    return Collections.singleton(new ComputedValue(resultSpec, labelledMatrix));
}

From source file:gov.nih.nci.caarray.util.CaArrayUtilsTest.java

@Test
public void testSplitValues() {
    assertTrue(/*from  w  w  w.  j  ava 2  s. co m*/
            Arrays.equals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, CaArrayUtils.splitIntoBooleans(EMPTY_STRING, " ")));
    assertTrue(Arrays.equals(new boolean[] { true }, CaArrayUtils.splitIntoBooleans("true", ",")));
    assertTrue(Arrays.equals(new boolean[] { true, false, true },
            CaArrayUtils.splitIntoBooleans("true;false;true", ";")));

    assertTrue(Arrays.equals(ArrayUtils.EMPTY_SHORT_ARRAY, CaArrayUtils.splitIntoShorts(EMPTY_STRING, " ")));
    assertTrue(Arrays.equals(new short[] { 0 }, CaArrayUtils.splitIntoShorts("0", ",")));
    assertTrue(Arrays.equals(new short[] { 3, 1, 2 }, CaArrayUtils.splitIntoShorts("3;1;2", ";")));

    assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, CaArrayUtils.splitIntoLongs(EMPTY_STRING, " ")));
    assertTrue(Arrays.equals(new long[] { 5L }, CaArrayUtils.splitIntoLongs("5", ",")));
    assertTrue(Arrays.equals(new long[] { 15L, 19L, 13L }, CaArrayUtils.splitIntoLongs("15/19/13", "/")));

    assertTrue(Arrays.equals(ArrayUtils.EMPTY_INT_ARRAY, CaArrayUtils.splitIntoInts(EMPTY_STRING, " ")));
    assertTrue(Arrays.equals(new int[] { 1001 }, CaArrayUtils.splitIntoInts("1001", ",")));
    assertTrue(Arrays.equals(new int[] { -1, 0, -2 }, CaArrayUtils.splitIntoInts("-1 0 -2", " ")));

    assertTrue(Arrays.equals(ArrayUtils.EMPTY_FLOAT_ARRAY, CaArrayUtils.splitIntoFloats(EMPTY_STRING, " ")));
    assertTrue(Arrays.equals(new float[] { 1.65f }, CaArrayUtils.splitIntoFloats("1.65", ",")));
    assertTrue(Arrays.equals(new float[] { 0f, 0.33f, -3.76f },
            CaArrayUtils.splitIntoFloats("0 0.33 -3.76", " ")));

    assertTrue(Arrays.equals(ArrayUtils.EMPTY_DOUBLE_ARRAY, CaArrayUtils.splitIntoDoubles(EMPTY_STRING, " ")));
    assertTrue(Arrays.equals(new double[] { 1.0 / 3.0 },
            CaArrayUtils.splitIntoDoubles("0.3333333333333333", ",")));
    assertTrue(Arrays.equals(new double[] { 0, -5.0 / 7.0, 11.0 / 13.0 },
            CaArrayUtils.splitIntoDoubles("0.0;-0.7142857142857143;0.8461538461538461", ";")));

    assertTrue(Arrays.equals(ArrayUtils.EMPTY_STRING_ARRAY, CaArrayUtils.splitFromCsv(EMPTY_STRING)));
    assertTrue(Arrays.equals(new String[] { "Iam,Dan" }, CaArrayUtils.splitFromCsv("Iam\\,Dan")));
    assertTrue(Arrays.equals(new String[] { "I", "m,e", "mi ne" }, CaArrayUtils.splitFromCsv("I,m\\,e,mi ne")));
}

From source file:edu.cornell.med.icb.goby.R.FisherExact.java

/**
 * Pass the fisher expression to R for computation.
 *
 * @param rengine          The R engine to use to calcuate the results.
 * @param fisherExpression The string representing the expression to evaluate.
 * @param is2x2matrix      Whether or not the data being evaluated represents a 2x2 matrix
 * @return The results of the evaluation (may be null if an exception interrupts the calculation)
 *//*from   w  w  w .  java  2  s . c o  m*/
private static Result evaluateFisherExpression(final Rengine rengine, final String fisherExpression,
        final boolean is2x2matrix) {
    // evaluate the R expression
    if (LOG.isDebugEnabled()) {
        LOG.debug("About to evaluate: " + fisherExpression);
    }
    final REXP fisherResultExpression = rengine.eval(fisherExpression);
    if (LOG.isDebugEnabled()) {
        LOG.debug(fisherResultExpression);
    }
    if (fisherResultExpression == null) {
        return null;
    }
    // the result from R is a vector/map of values
    final RVector fisherResultVector = fisherResultExpression.asVector();
    if (LOG.isDebugEnabled()) {
        LOG.debug(fisherResultVector);
    }

    // extract the p-value
    final REXP pValueExpression = fisherResultVector.at("p.value");
    final double pValue;
    if (pValueExpression != null) {
        pValue = pValueExpression.asDouble();
    } else {
        pValue = Double.NaN;
    }

    // extract the alternative hypothesis
    final REXP alternativeExpression = fisherResultVector.at("alternative");
    final String alternative = alternativeExpression.asString();
    if (LOG.isDebugEnabled()) {
        LOG.debug("alternative: " + alternative);
    }
    final AlternativeHypothesis alternativeHypothesis = AlternativeHypothesis
            .valueOf(StringUtils.remove(alternative, '.'));

    // some values are only returned when the input was a 2x2 matrix
    final double estimate;
    final double[] confidenceInterval;
    final double oddsRatio;

    if (is2x2matrix) {
        final REXP estimateExpression = fisherResultVector.at("estimate");
        if (estimateExpression != null) {
            estimate = estimateExpression.asDouble();
        } else {
            estimate = Double.NaN;
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug(estimateExpression);
            LOG.debug("estimate: " + estimate);
        }

        final REXP confidenceIntervalExpression = fisherResultVector.at("conf.int");
        if (confidenceIntervalExpression != null) {
            confidenceInterval = confidenceIntervalExpression.asDoubleArray();
        } else {
            confidenceInterval = ArrayUtils.EMPTY_DOUBLE_ARRAY;
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug(confidenceIntervalExpression);
            LOG.debug("confidenceInterval: " + ArrayUtils.toString(confidenceInterval));
        }

        final REXP oddsRatioExpression = fisherResultVector.at("null.value");
        if (oddsRatioExpression != null) {
            oddsRatio = oddsRatioExpression.asDouble();
        } else {
            oddsRatio = Double.NaN;
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug(oddsRatioExpression);
            LOG.debug("oddsRatio: " + ArrayUtils.toString(oddsRatio));
        }
    } else {
        // these values are not present in the 2xN case
        estimate = Double.NaN;
        confidenceInterval = ArrayUtils.EMPTY_DOUBLE_ARRAY;
        oddsRatio = Double.NaN;
    }

    return new Result(pValue, confidenceInterval, estimate, oddsRatio, alternativeHypothesis);
}

From source file:edu.cornell.med.icb.optimization.OptimizeSubSet.java

private void convertFittestToSolution(final IChromosome fittestChromosome) {
    if (fittestChromosome == null) {
        fitestSubset = null;//from   w  ww .j ava  2  s.com
        fitestParams = ArrayUtils.EMPTY_DOUBLE_ARRAY;
    } else {
        fitestSubset = ((SubsetSuperGene) fittestChromosome.getGene(0)).getSubSet();
        fitestParams = FitnessFunctionAdapter.getParameterValues(fittestChromosome, allPossibleParameterValues);

    }

}

From source file:gda.hrpd.pmac.EpicsCVScanController.java

private double[] get2Theta() {
    double[] x1 = ArrayUtils.EMPTY_DOUBLE_ARRAY;
    try {//from   w  w w . ja  v  a  2 s.com
        // logger.info("gets MAC1X");
        x1 = getMAC1X();
        // logger.info("gets MAC1X DONE");
    } catch (TimeoutException e) {
        logger.error("Timeout while gets MAC1X", e);
        e.printStackTrace();
    } catch (CAException e) {
        logger.error("CAException while gets MAC1X", e);
        e.printStackTrace();
    } catch (InterruptedException e) {
        logger.error("InterruptedException while gets MAC1X", e);
    }
    double[] x2 = ArrayUtils.EMPTY_DOUBLE_ARRAY;
    try {
        // logger.info("gets MAC2X");
        x2 = getMAC2X();
        // logger.info("gets MAC2X DONE");
    } catch (TimeoutException e) {
        logger.error("Timeout while gets MAC2X", e);
        e.printStackTrace();
    } catch (CAException e) {
        logger.error("CAException while gets MAC2X", e);
        e.printStackTrace();
    } catch (InterruptedException e) {
        logger.error("InterruptedException while gets MAC2X", e);
    }
    double[] x3 = ArrayUtils.EMPTY_DOUBLE_ARRAY;
    try {
        // logger.info("gets MAC3X");
        x3 = getMAC3X();
        // logger.info("gets MAC3X DONE");
    } catch (TimeoutException e) {
        logger.error("Timeout while gets MAC3X", e);
        e.printStackTrace();
    } catch (CAException e) {
        logger.error("CAException while gets MAC3X", e);
        e.printStackTrace();
    } catch (InterruptedException e) {
        logger.error("InterruptedException while gets MAC3X", e);
    }
    double[] x4 = ArrayUtils.EMPTY_DOUBLE_ARRAY;
    try {
        // logger.info("gets MAC4X");
        x4 = getMAC4X();
        // logger.info("gets MAC4X DONE");
    } catch (TimeoutException e) {
        logger.error("Timeout while gets MAC4X", e);
        e.printStackTrace();
    } catch (CAException e) {
        logger.error("CAException while gets MAC4X", e);
        e.printStackTrace();
    } catch (InterruptedException e) {
        logger.error("InterruptedException while gets MAC4X", e);
    }
    double[] x5 = ArrayUtils.EMPTY_DOUBLE_ARRAY;
    try {
        // logger.info("gets MAC5X");
        x5 = getMAC5X();
        // logger.info("gets MAC5X DONE");
    } catch (TimeoutException e) {
        logger.error("Timeout while gets MAC5X", e);
        e.printStackTrace();
    } catch (CAException e) {
        logger.error("CAException while gets MAC5X", e);
        e.printStackTrace();
    } catch (InterruptedException e) {
        logger.error("InterruptedException while gets MAC5X", e);
    }
    return ArrayUtils.subarray(
            ArrayUtils.addAll(ArrayUtils.addAll(ArrayUtils.addAll(ArrayUtils.addAll(x1, x2), x3), x4), x5),
            16500, 305000);
}

From source file:gda.hrpd.pmac.EpicsCVScanController.java

private double[] getCount() {
    double[] y1 = ArrayUtils.EMPTY_DOUBLE_ARRAY;
    try {//w w w.  j ava  2s .  c o m
        // logger.info("gets MAC1Y");
        y1 = getMAC1Y();
        // logger.info("gets MAC1Y DONE");
    } catch (TimeoutException e) {
        logger.error("Timeout while gets MAC1Y", e);
        e.printStackTrace();
    } catch (CAException e) {
        logger.error("CAException while gets MAC1Y", e);
        e.printStackTrace();
    } catch (InterruptedException e) {
        logger.error("InterruptedException while gets MAC1Y", e);
    }
    double[] y2 = ArrayUtils.EMPTY_DOUBLE_ARRAY;
    try {
        // logger.info("gets MAC2Y");
        y2 = getMAC2Y();
        // logger.info("gets MAC2Y DONE");
    } catch (TimeoutException e) {
        logger.error("Timeout while gets MAC2Y", e);
        e.printStackTrace();
    } catch (CAException e) {
        logger.error("CAException while gets MAC2Y", e);
        e.printStackTrace();
    } catch (InterruptedException e) {
        logger.error("InterruptedException while gets MAC2Y", e);
    }
    double[] y3 = ArrayUtils.EMPTY_DOUBLE_ARRAY;
    try {
        // logger.info("gets MAC3Y");
        y3 = getMAC3Y();
        // logger.info("gets MAC3Y DONE");
    } catch (TimeoutException e) {
        logger.error("Timeout while gets MAC3Y", e);
        e.printStackTrace();
    } catch (CAException e) {
        logger.error("CAException while gets MAC3Y", e);
        e.printStackTrace();
    } catch (InterruptedException e) {
        logger.error("InterruptedException while gets MAC3Y", e);
    }
    double[] y4 = ArrayUtils.EMPTY_DOUBLE_ARRAY;
    try {
        // logger.info("gets MAC4Y");
        y4 = getMAC4Y();
        // logger.info("gets MAC4Y DONE");
    } catch (TimeoutException e) {
        logger.error("Timeout while gets MAC4Y", e);
        e.printStackTrace();
    } catch (CAException e) {
        logger.error("CAException while gets MAC4Y", e);
        e.printStackTrace();
    } catch (InterruptedException e) {
        logger.error("InterruptedException while gets MAC4Y", e);
    }
    double[] y5 = ArrayUtils.EMPTY_DOUBLE_ARRAY;
    try {
        // logger.info("gets MAC5Y");
        y5 = getMAC5Y();
        // logger.info("gets MAC5Y DONE");
    } catch (TimeoutException e) {
        logger.error("Timeout while gets MAC5Y", e);
        e.printStackTrace();
    } catch (CAException e) {
        logger.error("CAException while gets MAC5Y", e);
        e.printStackTrace();
    } catch (InterruptedException e) {
        logger.error("InterruptedException while gets MAC5Y", e);
    }
    return ArrayUtils.subarray(
            ArrayUtils.addAll(ArrayUtils.addAll(ArrayUtils.addAll(ArrayUtils.addAll(y1, y2), y3), y4), y5),
            16500, 305000);
}

From source file:org.bdval.DiscoverWithGeneticAlgorithm.java

@Override
public void process(final DAVOptions options) {
    super.process(options);
    //final Table inputTable = options.inputTable;
    System.out.println("Optimizing " + (this.optimizeMeasureName));
    for (final ClassificationTask task : options.classificationTasks) {
        for (final GeneList geneList : options.geneLists) {
            int reducedNumProbeset;
            int iteration = 1;
            System.out.println("Processing gene list: " + geneList.toString());
            try {
                int numKept;
                GeneList activeGeneList = geneList;
                IntSet sourceSet = new IntArraySet();
                IntSet previousSubset = null;
                IntSet fitestSubSet = null;
                double[] fitestParamValues = ArrayUtils.EMPTY_DOUBLE_ARRAY;
                options.trainingPlatform = new GEOPlatformIndexed();
                Table processedTable = processTable(activeGeneList, options.inputTable, options,
                        MicroarrayTrainEvaluate.calculateLabelValueGroups(task));
                // try to free some memory (we cannot call processTable anymore after this:)
                options.inputTable = null;
                System.gc();/*from  w ww. j  a v  a  2  s.  com*/
                do {
                    System.out.println("Discover markers with GA wrapper for " + task);

                    final EvaluationMeasure evalMeasure;
                    if (iteration == 1) {

                        // FIRST ITERATION

                        final ClassificationHelper helper = getClassifier(processedTable,
                                MicroarrayTrainEvaluate.calculateLabelValueGroups(task));
                        final RandomEngine randomEngine = new MersenneTwister(options.randomSeed);
                        final CrossValidation CV = new CrossValidation(helper.classifier, helper.problem,
                                randomEngine);
                        final boolean useR = optimizationRequiresR();
                        CV.useRServer(useR); // user R server only when required.
                        CV.setRepeatNumber(cvRepeatNumber);
                        CV.setScalerClass(options.scalerClass);

                        if (useRServer) {
                            CV.evaluateMeasure(optimizeMeasureName);
                        }
                        //            CV.setScalerClass(PercentileScalingRowProcessor.class);
                        evalMeasure = CV.crossValidation(foldNumber);

                        System.out.println("Initial " + getPerformanceMeasureName() + " measure: "
                                + getOptimizationMeasure(evalMeasure));
                        numKept = options.trainingPlatform.getProbeIds().size();

                        for (int i = 0; i < numKept; i++) {
                            sourceSet.add(i);
                        }
                        inputIdentifiers = options.trainingPlatform;

                        if (numKept <= numProbesets) {
                            LOG.error("Cannot remove probesets, already below the target number.");
                            fitestSubSet = sourceSet;
                            break;
                        }
                    } else {
                        numKept = previousSubset.size();
                        sourceSet = previousSubset;

                    }
                    localOptions = options;
                    System.out.println("Num probeset as input : " + numKept);

                    final SubSetFitnessFunction convergenceCriterion;
                    final Table processedTableConstant = processedTable;
                    convergenceCriterion = new AbstractSubSetFitnessFunction() {
                        @Override
                        public double evaluate(final IntSet subset, final double[] paramValues) {
                            try {

                                GeneList geneListFromSubset = convertSubsetToGeneList(subset);

                                Table filteredTable = filterTable(options, processedTableConstant,
                                        geneListFromSubset);

                                ClassificationHelper helper = getClassifier(filteredTable,
                                        MicroarrayTrainEvaluate.calculateLabelValueGroups(task));
                                int paramIndex = 0;
                                for (final String parameterName : getParameterNames(discreteParameters)) {
                                    helper.parameters.setParameter(parameterName, paramValues[paramIndex++]);
                                }
                                helper.classifier.setParameters(helper.parameters);
                                RandomEngine randomEngine = new MersenneTwister(options.randomSeed);

                                CrossValidation CV = new CrossValidation(helper.classifier, helper.problem,
                                        randomEngine);
                                final boolean useR = optimizationRequiresR();

                                CV.useRServer(useR);
                                CV.setRepeatNumber(cvRepeatNumber);
                                CV.setScalerClass(options.scalerClass);
                                CV.evaluateMeasure(optimizeMeasureName);

                                final EvaluationMeasure eMeasure = CV.crossValidation(foldNumber);

                                geneListFromSubset = null;
                                filteredTable = null;
                                helper = null;
                                randomEngine = null;
                                CV = null;

                                final double measure = getOptimizationMeasure(eMeasure);
                                LOG.info(task.getExperimentDataFilename() + " evaluated "
                                        + getPerformanceMeasureName() + " " + measure);

                                //                                                double std = getOptimizationMeasureStd(eMeasure);

                                // return measure -std;
                                return measure;

                            } catch (InvalidColumnException e) {
                                LOG.error(e);
                                System.exit(10);
                            } catch (TypeMismatchException e) {
                                LOG.error(e);
                                System.exit(10);
                            }
                            throw new InternalError("This statement should never be reached.");
                        }
                    };

                    reducedNumProbeset = Math.max(numProbesets, (int) (numKept * ratio));

                    if (reducedNumProbeset == numKept) {
                        System.out.println("Previous step optimized the same number of probesets already.");
                        break;
                    } else {
                        System.out.println("Optimizing to keep " + reducedNumProbeset + " probesets.");
                    }
                    final OptimizeSubSet optimizationEngine = new OptimizeSubSet(sourceSet, reducedNumProbeset,
                            convergenceCriterion, populationSize, discreteParameters);
                    optimizationEngine.setModuloProgressReport(2);

                    optimizationEngine.optimize(numOptimizationStepsPerIteration, .001);
                    fitestSubSet = optimizationEngine.getFitestSubset();
                    fitestParamValues = optimizationEngine.getFitestParameterValues();
                    previousSubset = fitestSubSet;
                    // use as gene list for the next iteration: the restriction of the previous gene list
                    // to those probesets that were found with to have the bext F-1 measure in this iteration.

                    activeGeneList = convertSubsetToGeneList(fitestSubSet);
                    System.out.println("numKept: " + numKept + " reducedNumber: " + reducedNumProbeset);
                    if (!writeGeneListFormat) {
                        // print intermediate result for this iteration.
                        printFeatures(options, iteration, fitestSubSet,
                                convergenceCriterion.evaluate(fitestSubSet, fitestParamValues));
                    }
                    iteration++;

                    final GeneList geneListFromSubset = convertSubsetToGeneList(fitestSubSet);

                    final Table fitestTable = filterTable(options, processedTable, geneListFromSubset);
                    processedTable = fitestTable;

                    // hint to the JVM that this would be a good time to garbage collect.
                    System.gc();
                } while (numKept > numProbesets);

                printFeatures(options, iteration, fitestSubSet, 0);
                printFitestParamValues(options, fitestParamValues, getParameterNames(discreteParameters));
            } catch (Exception e) {
                LOG.error(e);
                e.printStackTrace();
                System.exit(10);
            }
        }
    }
}

From source file:org.bdval.signalquality.SimpleSignalQualityCalculator.java

/**
 * Compute the signal quality between the two sets of data.
 * Input maps have a key of the probe id, such as "AA799301_Probe1"
 * Map value per key is a double[] of values.
 * <p/>//from  w  w  w.  java2  s.  c o  m
 * One idea Fabien had is to write a TSV file that contains
 * ModelID  Feature  p-Value
 * for all models and then do various post processing on that one
 * file using a separate tool instead of doing the entire calculation here?
 *
 * @param model             the model we are writing
 * @param modelId           the model id we are calculating the signal quality for
 * @param classToDataMapMap map of classes + "-training"/"-validation" to the
 * map of feature to raw data.
 */
@Override
public void calculatePValues(final BDVModel model, final String modelId, final String[] allClasses,
        final Map<String, Map<String, double[]>> classToDataMapMap) {

    // Call calculate in AbstractSignalQualityCalculator first
    super.calculatePValues(model, modelId, allClasses, classToDataMapMap);

    // System.out.println("(simple) Calculating signal quality for model " + modelId);

    // Calculate pValues and write them

    // Aquire the ENITRE feature set from both training and validation
    allFeaturesSet.clear();
    for (final String sampleClass : allClasses) {
        final Map<String, double[]> trainingDataMap = classToDataMapMap.get(sampleClass + "-training");
        final Map<String, double[]> validationDataMap = classToDataMapMap.get(sampleClass + "-validation");
        allFeaturesSet.addAll(trainingDataMap.keySet());
        allFeaturesSet.addAll(validationDataMap.keySet());
    }

    for (final String featureId : allFeaturesSet) {

        double[] trainingData = null;
        double[] validationData = null;
        try {
            data.clear();
            data.put("model-id", modelId);
            data.put("feature", featureId);
            for (int classIndex = 0; classIndex < allClasses.length; classIndex++) {
                final String classId = allClasses[classIndex];
                final String classIdAppend = "[" + CLASS_TRANSLATION[classIndex] + "]";
                trainingData = classToDataMapMap.get(classId + "-training").get(featureId);
                if (trainingData == null) {
                    trainingData = ArrayUtils.EMPTY_DOUBLE_ARRAY;
                }
                validationData = classToDataMapMap.get(classId + "-validation").get(featureId);
                if (validationData == null) {
                    validationData = ArrayUtils.EMPTY_DOUBLE_ARRAY;
                }
                if (trainingData.length == 0 || validationData.length == 0) {
                    if (trainingData.length == 0) {
                        writeData(String.format("# modelId=%s, featureId=%s, class=%s has no training data.",
                                modelId, featureId, classId));
                    }
                    if (validationData.length == 0) {
                        writeData(String.format("# modelId=%s, featureId=%s, class=%s has no validation data.",
                                modelId, featureId, classId));
                    }
                    continue;
                }
                // System.out.printf("Training data size = %s Validation data size = %d%n",
                //         trainingData.length, validationData.length);

                if (dataToPvalueScript == null) {
                    dataToPvalueScript = RScript.createFromResource("rscripts/data_to_pvalue.R");
                }

                dataToPvalueScript.setInput("x", trainingData);
                dataToPvalueScript.setInput("y", validationData);

                dataToPvalueScript.setOutput("p_value", RDataObjectType.Double);
                dataToPvalueScript.setOutput("test_statistic", RDataObjectType.Double);
                dataToPvalueScript.setOutput("sum_rank_features", RDataObjectType.DoubleArray);
                dataToPvalueScript.execute();

                final double pvalue = dataToPvalueScript.getOutputDouble("p_value");
                final double testStatistic = dataToPvalueScript.getOutputDouble("test_statistic");
                final double[] sumRankFeatures = dataToPvalueScript.getOutputDoubleArray("sum_rank_features");

                data.put("p-value" + classIdAppend, pvalue);
                data.put("test-statistics" + classIdAppend, testStatistic);
                data.put("t1" + classIdAppend, sumRankFeatures[0]);
                data.put("t2" + classIdAppend, sumRankFeatures[1]);
                if (model != null) {
                    data.put("mean" + classIdAppend, model.getTrainingSetMeanValue(featureId));
                    data.put("range" + classIdAppend, model.getTrainingSetRangeValue(featureId));
                } else {
                    data.put("mean" + classIdAppend, -1d);
                    data.put("range" + classIdAppend, -1d);
                }
                data.put("training-values" + classIdAppend, trainingData);
                data.put("validation-values" + classIdAppend, validationData);
            }
            writeData(data);
        } catch (Exception e) {
            LOG.error("Could not calculate KS-test. " + "Error data written to comment in output file");
            writeData(String.format("# ERROR WITH %s.%s.trainingData=%s", modelId, featureId,
                    ArrayUtils.toString(trainingData)));
            writeData(String.format("# ERROR WITH %s.%s.validationData=%s", modelId, featureId,
                    ArrayUtils.toString(validationData)));
        }
    }
}