Example usage for org.apache.commons.math3.stat.descriptive DescriptiveStatistics DescriptiveStatistics

List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics DescriptiveStatistics

Introduction

In this page you can find the example usage for org.apache.commons.math3.stat.descriptive DescriptiveStatistics DescriptiveStatistics.

Prototype

public DescriptiveStatistics() 

Source Link

Document

Construct a DescriptiveStatistics instance with an infinite window

Usage

From source file:gdsc.smlm.ij.plugins.SummariseResults.java

private void addSummary(MemoryPeakResults result) {
    DescriptiveStatistics[] stats = new DescriptiveStatistics[2];
    for (int i = 0; i < stats.length; i++) {
        stats[i] = new DescriptiveStatistics();
    }// w w w  .  ja  v  a  2  s.com

    // Only process the statistics if we have a noise component
    final int size = result.size();
    if (size > 0 && result.getResults().get(0).noise > 0) {

        int ii = 0;
        final double nmPerPixel = result.getNmPerPixel();
        final double gain = result.getGain();
        final boolean emCCD = result.isEMCCD();
        for (PeakResult peakResult : result.getResults()) {
            if (peakResult == null) {
                System.out.printf("Null result in summary @ %d\n", ++ii);
                continue;
            }
            stats[0].addValue(peakResult.getPrecision(nmPerPixel, gain, emCCD));
            stats[1].addValue(peakResult.getSignal() / peakResult.noise);
        }
    }

    StringBuilder sb = new StringBuilder();
    sb.append(result.getName());
    sb.append("\t").append(result.size());
    int maxT = getMaxT(result);
    sb.append("\t").append(maxT);
    final double exposureTime = (result.getCalibration() != null) ? result.getCalibration().exposureTime : 0;
    sb.append("\t").append(Utils.timeToString(maxT * exposureTime));
    if (size > 0) {
        boolean includeDeviations = result.getResults().get(0).paramsStdDev != null;
        long memorySize = MemoryPeakResults.estimateMemorySize(size, includeDeviations);
        String memory = MemoryPeakResults.memorySizeString(memorySize);
        sb.append("\t").append(memory);
    } else {
        sb.append("\t-");
    }
    Rectangle bounds = result.getBounds(true);
    sb.append(String.format("\t%d,%d,%d,%d\t%s\t%s\t%s", bounds.x, bounds.y, bounds.x + bounds.width,
            bounds.y + bounds.height, Utils.rounded(result.getNmPerPixel(), 4),
            Utils.rounded(result.getGain(), 4), Utils.rounded(exposureTime, 4)));
    for (int i = 0; i < stats.length; i++) {
        if (Double.isNaN(stats[i].getMean())) {
            sb.append("\t-\t-\t-\t-");
        } else {
            sb.append("\t").append(IJ.d2s(stats[i].getMean(), 3));
            sb.append("\t").append(IJ.d2s(stats[i].getPercentile(50), 3));
            sb.append("\t").append(IJ.d2s(stats[i].getMin(), 3));
            sb.append("\t").append(IJ.d2s(stats[i].getMax(), 3));
        }
    }

    summary.append(sb.toString());
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.sequence.evaluation.thirdparty.SegEvalEvaluator.java

/**
 * Takes each file from the {@code predictionsFolder} and evaluate it against its counterpart
 * from the {@code goldFolder} using boundary similarity metric.
 *
 * @param goldFolder             gold data
 * @param predictionsFolder      predictions (or any other data, ie. from annotators)
 * @param argumentComponentClass which argument component should be considered
 * @return statistics/*from   w  w  w  .j a  va2 s. c om*/
 * @throws Exception
 */
public DescriptiveStatistics evaluateFolders(File goldFolder, File predictionsFolder,
        Class<ArgumentComponent> argumentComponentClass) throws Exception {
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    File[] files = predictionsFolder.listFiles(JCasIOHelper.XMI_FILTER);
    //        System.out.println("Predicted files size: " + files.length);

    for (File predicted : files) {
        File gold = new File(goldFolder, predicted.getName());

        if (!gold.exists()) {
            throw new IOException("Gold file " + gold + " does not exist!");
        }

        JCas goldJCas = JCasIOHelper.loadJCasFromFile(gold);
        JCas predictedJCas = JCasIOHelper.loadJCasFromFile(predicted);

        double boundarySimilarity = evaluate(goldJCas, predictedJCas, argumentComponentClass);

        statistics.addValue(boundarySimilarity);
    }

    return statistics;
}

From source file:cc.kave.commons.pointsto.evaluation.runners.ProjectStoreRunner.java

private static void countRecvCallSites(Collection<ICoReTypeName> types, ProjectUsageStore store)
        throws IOException {
    DescriptiveStatistics statistics = new DescriptiveStatistics();
    for (ICoReTypeName type : types) {
        if (store.getProjects(type).size() < 10) {
            continue;
        }//  w  ww  .ja v  a2 s .  c o  m

        int numDistinctRecvCallsite = store.load(type, new PointsToUsageFilter()).stream()
                .flatMap(usage -> usage.getReceiverCallsites().stream()).map(CallSite::getMethod)
                .collect(Collectors.toSet()).size();
        if (numDistinctRecvCallsite > 0) {
            statistics.addValue(numDistinctRecvCallsite);
            System.out.printf(Locale.US, "%s: %d\n", CoReNames.vm2srcQualifiedType(type),
                    numDistinctRecvCallsite);
        }
    }
    System.out.println();
    System.out.printf(Locale.US, "mean: %.3f, stddev: %.3f, median: %.1f\n", statistics.getMean(),
            statistics.getStandardDeviation(), statistics.getPercentile(50));
}

From source file:com.itemanalysis.psychometrics.measurement.TestSummary.java

public TestSummary(int numberOfItems, int numberOfSubscales, ArrayList<Integer> cutScores,
        ArrayList<VariableAttributes> variableAttributes, boolean unbiased, boolean deletedReliability,
        boolean showCsem) {
    this.numberOfItems = numberOfItems;

    if (cutScores != null) {
        this.cutScores = new int[cutScores.size()];
        int i = 0;
        for (Integer intgr : cutScores) {
            this.cutScores[i] = intgr.intValue();
            i++;/* w  w  w.  ja v a  2s .  c  o m*/
        }
    }

    this.variableAttributes = variableAttributes;
    this.unbiased = unbiased;
    this.deletedReliability = deletedReliability;
    this.showCsem = showCsem;
    stats = new DescriptiveStatistics();
    stdDev = new StandardDeviation(unbiased);
    relMatrix = new CovarianceMatrix(variableAttributes);
    this.numberOfSubscales = numberOfSubscales;
    if (numberOfSubscales > 1)
        partRelMatrix = new CovarianceMatrix(numberOfSubscales);
}

From source file:com.clust4j.algo.preprocess.RobustScaler.java

@Override
public RobustScaler fit(RealMatrix X) {
    synchronized (fitLock) {
        this.centerer = new MedianCenterer().fit(X);

        // Get percentile
        final int n = X.getColumnDimension();
        double[][] transpose = X.transpose().getData();

        // top row will be 25th, bottom 75
        double[][] quantiles_25_75 = new double[2][n];

        // Quantile engine
        DescriptiveStatistics stats;//from  w  w w  .jav a2  s . com
        for (int j = 0; j < n; j++) {
            stats = new DescriptiveStatistics();

            for (int i = 0; i < transpose[j].length; i++) {
                stats.addValue(transpose[j][i]);
            }

            quantiles_25_75[0][j] = stats.getPercentile(25);
            quantiles_25_75[0][j] = stats.getPercentile(75);
        }

        // set the scale
        this.scale = VecUtils.subtract(quantiles_25_75[1], quantiles_25_75[0]);

        // If we have a constant value, we might get zeroes in the scale:
        for (int i = 0; i < scale.length; i++) {
            if (scale[i] == 0) {
                scale[i] = 1.0;
            }
        }

        return this;
    }
}

From source file:com.intuit.tank.vm.common.util.ReportUtilCpTest.java

/**
 * Run the String[] getSummaryData(String,DescriptiveStatistics) method test.
 * /*w w  w .  ja  v  a2s . co  m*/
 * @throws Exception
 * 
 * @generatedBy CodePro at 9/3/14 3:41 PM
 */
@Test
public void testGetSummaryData_2() throws Exception {
    String key = "";
    DescriptiveStatistics stats = new DescriptiveStatistics();

    String[] result = ReportUtil.getSummaryData(key, stats);

    assertNotNull(result);
    assertEquals(23, result.length);
    assertEquals("", result[0]);
    assertEquals("0", result[1]);
    assertEquals("", result[2]);
    assertEquals("", result[3]);
    assertEquals("", result[4]);
    assertEquals("", result[5]);
    assertEquals("", result[6]);
    assertEquals("", result[7]);
    assertEquals("", result[8]);
    assertEquals("", result[9]);
    assertEquals("", result[10]);
    assertEquals("", result[11]);
    assertEquals("", result[12]);
    assertEquals("", result[13]);
    assertEquals("", result[14]);
    assertEquals("", result[15]);
    assertEquals("", result[16]);
    assertEquals("", result[17]);
    assertEquals("", result[18]);
    assertEquals("", result[19]);
    assertEquals("", result[20]);
    assertEquals(null, result[21]);
    assertEquals(null, result[22]);
}

From source file:com.ttolley.pongbot.opencv.CvWorker.java

public CvWorker() {
    yPos = new DescriptiveStatistics();
    xPos = new DescriptiveStatistics();
    xPos.setWindowSize(10);/*from w w  w.  ja  v  a 2 s .  c o  m*/
    yPos.setWindowSize(10);

    try {
        // Load the native library.  
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        capture = new VideoCapture(1);

    } catch (Exception ex) {
        System.out.println(ex.getCause().getMessage());
    }

}

From source file:com.screenslicer.core.scrape.type.ComparableNode.java

public ComparableNode(final Node node) {
    this.node = node;
    List<Node> separated = node.childNodes();
    int children = 0;
    int childBlocks = 0;
    int childFormatting = 0;
    int childContent = 0;
    int childItems = 0;
    int childDecoration = 0;
    int anchorChildren = 0;
    int textChildren = 0;
    int anchorTextChildren = 0;
    int anchorChildItems = 0;
    int textChildItems = 0;
    int anchorTextChildItems = 0;
    int itemChars = 0;
    int itemAnchorChars = 0;
    List<String> firstChildTags = null;
    List<List<String>> orderedTags = new ArrayList<List<String>>();
    List<String> allChildTags = new ArrayList<String>();
    ArrayList<List<String>> childTags = new ArrayList<List<String>>();
    boolean childrenConsistent = true;
    String childName = null;/*from   w w w .j av a  2 s . co m*/
    boolean childrenSame = true;
    double avgChildLengthDouble = 0d;
    int nodeStrLen = Util.trimmedLen(node.toString());
    DescriptiveStatistics statAnchorChars = new DescriptiveStatistics();
    DescriptiveStatistics statAnchors = new DescriptiveStatistics();
    DescriptiveStatistics statChars = new DescriptiveStatistics();
    DescriptiveStatistics statDescendants = new DescriptiveStatistics();
    DescriptiveStatistics statFields = new DescriptiveStatistics();
    DescriptiveStatistics statLevels = new DescriptiveStatistics();
    DescriptiveStatistics statLongestField = new DescriptiveStatistics();
    DescriptiveStatistics statNonAnchorChars = new DescriptiveStatistics();
    DescriptiveStatistics statTextAnchors = new DescriptiveStatistics();
    DescriptiveStatistics statStrLen = new DescriptiveStatistics();
    DescriptiveStatistics statItemChars = new DescriptiveStatistics();
    DescriptiveStatistics statItemAnchorChars = new DescriptiveStatistics();
    for (Node child : separated) {
        if (!Util.isEmpty(child)) {
            children++;
            int childStrLen = Util.trimmedLen(child.toString());
            avgChildLengthDouble += childStrLen;
            NodeCounter counter = new NodeCounter(child);
            if (Util.isItem(child.nodeName())) {
                ++childItems;
                anchorChildItems += counter.anchors() > 0 ? 1 : 0;
                textChildItems += counter.fields() > 0 ? 1 : 0;
                anchorTextChildItems += counter.anchors() > 0 && counter.fields() > 0 ? 1 : 0;
                itemChars += counter.chars();
                itemAnchorChars += counter.anchorChars();
                statItemChars.addValue(counter.chars());
                statItemAnchorChars.addValue(counter.anchorChars());
            }
            if (Util.isBlock(child.nodeName())) {
                ++childBlocks;
            }
            if (Util.isDecoration(child.nodeName())) {
                ++childDecoration;
            }
            if (Util.isFormatting(child.nodeName())) {
                ++childFormatting;
            }
            if (Util.isContent(child)) {
                ++childContent;
            }

            anchorChildren += counter.anchors() > 0 ? 1 : 0;
            textChildren += counter.fields() > 0 ? 1 : 0;
            anchorTextChildren += counter.anchors() > 0 && counter.fields() > 0 ? 1 : 0;

            statAnchorChars.addValue(counter.anchorChars());
            statAnchors.addValue(counter.anchors());
            statChars.addValue(counter.chars());
            statDescendants.addValue(counter.descendants());
            statFields.addValue(counter.fields());
            statLevels.addValue(counter.levels());
            statLongestField.addValue(counter.longestField());
            statNonAnchorChars.addValue(counter.nonAnchorChars());
            statTextAnchors.addValue(counter.textAnchors());
            statStrLen.addValue(childStrLen);

            List<String> curChildTags = counter.tags();
            allChildTags = Util.join(allChildTags, curChildTags);
            childTags.add(curChildTags);
            if (firstChildTags == null) {
                firstChildTags = curChildTags;
            } else if (childrenConsistent && !Util.isSame(firstChildTags, curChildTags)) {
                childrenConsistent = false;
            }

            if (childName == null) {
                childName = child.nodeName();
            } else if (childrenSame && !childName.equals(child.nodeName())) {
                childrenSame = false;
            }

            if (!Util.contains(counter.orderedTags(), orderedTags)) {
                orderedTags.add(counter.orderedTags());
            }
        }
    }
    avgChildLengthDouble = children == 0 ? 0 : avgChildLengthDouble / (double) children;
    int avgChildLength = (int) avgChildLengthDouble;
    double avgChildDiff = 0;
    int maxChildDiff = 0;
    for (List<String> tagList : childTags) {
        avgChildDiff += allChildTags.size() - tagList.size();
        maxChildDiff = Math.max(maxChildDiff, allChildTags.size() - tagList.size());
    }
    avgChildDiff = childTags.size() == 0 ? 0 : avgChildDiff / (double) childTags.size();

    childrenConsistent = firstChildTags != null && !firstChildTags.isEmpty() && childrenConsistent;

    NodeCounter counter = new NodeCounter(separated);
    int siblings = 0;
    for (Node sibling : node.parent().childNodes()) {
        if (!Util.isEmpty(sibling)) {
            siblings++;
        }
    }
    this.scores = new int[] { counter.items(), counter.blocks(), counter.decoration(), counter.formatting(),
            counter.content(), div(counter.items(), children), div(counter.blocks(), children),
            div(counter.decoration(), children), div(counter.formatting(), children),
            div(counter.content(), children),

            childItems, childBlocks, childDecoration, childFormatting, childContent, avgChildLength,

            counter.fields(), textChildItems, counter.images(), counter.anchors(), counter.textAnchors(),
            div(counter.chars(), Math.max(1, counter.fields())), div(itemChars, Math.max(1, textChildItems)),

            counter.longestField(), nodeStrLen, div(nodeStrLen, children), counter.anchorLen(), counter.chars(),
            itemChars, div(counter.chars(), children), div(itemChars, childItems), counter.nonAnchorChars(),
            div(counter.nonAnchorChars(), children), div(counter.nonAnchorChars(), childItems),
            div(counter.nonAnchorChars(), childBlocks), div(counter.nonAnchorChars(), childContent),
            div(counter.nonAnchorChars(), counter.anchors()),
            div(counter.nonAnchorChars(), counter.textAnchors()), counter.anchorChars(), itemAnchorChars,
            div(itemAnchorChars, anchorChildItems), div(counter.anchorChars(), counter.anchors()),
            div(counter.anchorChars(), counter.textAnchors()), div(counter.anchorChars(), children),

            counter.descendants(), counter.levels(), div(counter.descendants(), children),
            div(children, counter.levels()), siblings, children,

            maxChildDiff, toInt(avgChildDiff), toInt(childrenSame), toInt(childrenConsistent),
            orderedTags.size(),

            mod0(children, RESULT_GROUP_LARGE), mod0(children, RESULT_GROUP_SMALL),
            distance(children, RESULT_GROUP_LARGE), distance(children, RESULT_GROUP_SMALL),
            mod0(childItems, RESULT_GROUP_LARGE), mod0(childItems, RESULT_GROUP_SMALL),
            distance(childItems, RESULT_GROUP_LARGE), distance(childItems, RESULT_GROUP_SMALL),
            mod0(childBlocks, RESULT_GROUP_LARGE), mod0(childBlocks, RESULT_GROUP_SMALL),
            distance(childBlocks, RESULT_GROUP_LARGE), distance(childBlocks, RESULT_GROUP_SMALL),
            mod0(childContent, RESULT_GROUP_LARGE), mod0(childContent, RESULT_GROUP_SMALL),
            distance(childContent, RESULT_GROUP_LARGE), distance(childContent, RESULT_GROUP_SMALL),
            mod0(counter.anchors(), RESULT_GROUP_LARGE), mod0(counter.anchors(), RESULT_GROUP_SMALL),
            distance(counter.anchors(), RESULT_GROUP_LARGE), distance(counter.anchors(), RESULT_GROUP_SMALL),
            mod0(anchorChildItems, RESULT_GROUP_LARGE), mod0(anchorChildItems, RESULT_GROUP_SMALL),
            distance(anchorChildItems, RESULT_GROUP_LARGE), distance(anchorChildItems, RESULT_GROUP_SMALL),
            mod0(textChildItems, RESULT_GROUP_LARGE), mod0(textChildItems, RESULT_GROUP_SMALL),
            distance(textChildItems, RESULT_GROUP_LARGE), distance(textChildItems, RESULT_GROUP_SMALL),
            mod0(counter.textAnchors(), RESULT_GROUP_LARGE), mod0(counter.textAnchors(), RESULT_GROUP_SMALL),
            distance(counter.textAnchors(), RESULT_GROUP_LARGE),
            distance(counter.textAnchors(), RESULT_GROUP_SMALL),

            Math.abs(children - counter.anchors()), Math.abs(childItems - counter.anchors()),
            evenlyDivisible(children, counter.anchors()), evenlyDivisible(childItems, counter.anchors()),
            smallestMod(children, counter.anchors()), smallestMod(childItems, counter.anchors()),

            Math.abs(children - counter.textAnchors()), Math.abs(childItems - counter.textAnchors()),
            Math.abs(children - anchorChildren), Math.abs(childItems - anchorChildItems),
            Math.abs(children - textChildren), Math.abs(childItems - textChildItems),
            Math.abs(children - anchorTextChildren), Math.abs(childItems - anchorTextChildItems),
            evenlyDivisible(children, counter.textAnchors()),
            evenlyDivisible(childItems, counter.textAnchors()), evenlyDivisible(children, anchorChildren),
            evenlyDivisible(childItems, anchorChildItems), evenlyDivisible(children, textChildren),
            evenlyDivisible(childItems, textChildItems), evenlyDivisible(children, anchorTextChildren),
            evenlyDivisible(childItems, anchorTextChildItems), smallestMod(children, counter.textAnchors()),
            smallestMod(childItems, counter.textAnchors()), smallestMod(children, anchorChildren),
            smallestMod(childItems, anchorChildItems), smallestMod(children, textChildren),
            smallestMod(childItems, textChildItems), smallestMod(children, anchorTextChildren),
            smallestMod(childItems, anchorTextChildItems),

            Math.abs(anchorChildren - anchorChildItems), Math.abs(textChildren - textChildItems),
            Math.abs(anchorTextChildren - anchorTextChildItems),

            toInt(statAnchorChars.getSkewness()), toInt(statAnchorChars.getStandardDeviation()),
            toInt(statAnchorChars.getMean()), toInt(statAnchors.getSkewness()),
            toInt(statAnchors.getStandardDeviation()), toInt(statAnchors.getMean()),
            toInt(statChars.getSkewness()), toInt(statChars.getStandardDeviation()), toInt(statChars.getMean()),
            toInt(statDescendants.getSkewness()), toInt(statDescendants.getStandardDeviation()),
            toInt(statDescendants.getMean()), toInt(statFields.getSkewness()),
            toInt(statFields.getStandardDeviation()), toInt(statFields.getMean()),
            toInt(statLevels.getSkewness()), toInt(statLevels.getStandardDeviation()),
            toInt(statLevels.getMean()), toInt(statLongestField.getSkewness()),
            toInt(statLongestField.getStandardDeviation()), toInt(statLongestField.getMean()),
            toInt(statNonAnchorChars.getSkewness()), toInt(statNonAnchorChars.getStandardDeviation()),
            toInt(statNonAnchorChars.getMean()), toInt(statStrLen.getSkewness()),
            toInt(statStrLen.getStandardDeviation()), toInt(statStrLen.getMean()),
            toInt(statTextAnchors.getSkewness()), toInt(statTextAnchors.getStandardDeviation()),
            toInt(statTextAnchors.getMean()), toInt(statItemChars.getSkewness()),
            toInt(statItemChars.getStandardDeviation()), toInt(statItemChars.getMean()),
            toInt(statItemAnchorChars.getSkewness()), toInt(statItemAnchorChars.getStandardDeviation()),
            toInt(statItemAnchorChars.getMean()), };
}

From source file:com.facebook.presto.operator.aggregation.AbstractTestApproximateCountDistinct.java

@Test(dataProvider = "provideStandardErrors")
public void testMultiplePositions(double maxStandardError) throws Exception {
    DescriptiveStatistics stats = new DescriptiveStatistics();

    for (int i = 0; i < 500; ++i) {
        int uniques = ThreadLocalRandom.current().nextInt(20000) + 1;

        List<Object> values = createRandomSample(uniques, (int) (uniques * 1.5));

        long actual = estimateGroupByCount(values, maxStandardError);
        double error = (actual - uniques) * 1.0 / uniques;

        stats.addValue(error);//from   w w w  . j av a2 s. co  m
    }

    assertLessThan(stats.getMean(), 1.0e-2);
    assertLessThan(Math.abs(stats.getStandardDeviation() - maxStandardError), 1.0e-2);
}

From source file:com.caseystella.analytics.outlier.batch.rpca.RPCAOutlierAlgorithm.java

public double outlierScore(List<DataPoint> dataPoints, DataPoint value) {
    double[] inputData = new double[dataPoints.size() + 1];
    int numNonZero = 0;
    if (scaling != ScalingFunctions.NONE) {
        int i = 0;
        final DescriptiveStatistics stats = new DescriptiveStatistics();
        for (DataPoint dp : dataPoints) {
            inputData[i++] = dp.getValue();

            stats.addValue(dp.getValue());
            numNonZero += dp.getValue() > EPSILON ? 1 : 0;
        }/*w ww .  j  ava 2s  .co m*/
        inputData[i] = value.getValue();
        GlobalStatistics globalStats = new GlobalStatistics() {
            {
                setMax(stats.getMax());
                setMin(stats.getMin());
                setMax(stats.getMean());
                setStddev(stats.getStandardDeviation());
            }
        };
        for (i = 0; i < inputData.length; ++i) {
            inputData[i] = scaling.scale(inputData[i], globalStats);
        }
    } else {
        int i = 0;
        for (DataPoint dp : dataPoints) {
            inputData[i++] = dp.getValue();
            numNonZero += dp.getValue() > EPSILON ? 1 : 0;
        }
        inputData[i] = value.getValue();
    }
    int nCols = 1;
    int nRows = inputData.length;
    if (numNonZero > minRecords) {
        AugmentedDickeyFuller dickeyFullerTest = new AugmentedDickeyFuller(inputData);
        double[] inputArrayTransformed = inputData;
        if (!this.isForceDiff && dickeyFullerTest.isNeedsDiff()) {
            // Auto Diff
            inputArrayTransformed = dickeyFullerTest.getZeroPaddedDiff();
        } else if (this.isForceDiff) {
            // Force Diff
            inputArrayTransformed = dickeyFullerTest.getZeroPaddedDiff();
        }

        if (this.spenalty == null) {
            this.lpenalty = this.LPENALTY_DEFAULT;
            this.spenalty = this.SPENALTY_DEFAULT / Math.sqrt(Math.max(nCols, nRows));
        }

        // Calc Mean
        double mean = 0;
        for (int n = 0; n < inputArrayTransformed.length; n++) {
            mean += inputArrayTransformed[n];
        }
        mean /= inputArrayTransformed.length;

        // Calc STDEV
        double stdev = 0;
        for (int n = 0; n < inputArrayTransformed.length; n++) {
            stdev += Math.pow(inputArrayTransformed[n] - mean, 2);
        }
        stdev = Math.sqrt(stdev / (inputArrayTransformed.length - 1));

        // Transformation: Zero Mean, Unit Variance
        for (int n = 0; n < inputArrayTransformed.length; n++) {
            inputArrayTransformed[n] = (inputArrayTransformed[n] - mean) / stdev;
        }

        // Read Input Data into Array
        // Read Input Data into Array
        double[][] input2DArray = new double[nRows][nCols];
        input2DArray = VectorToMatrix(inputArrayTransformed, nRows, nCols);

        RPCA rSVD = new RPCA(input2DArray, this.lpenalty, this.spenalty);

        double[][] outputE = rSVD.getE().getData();
        double[][] outputS = rSVD.getS().getData();
        double[][] outputL = rSVD.getL().getData();
        return outputS[nRows - 1][0];
    } else {
        return Double.NaN;
    }
}