Java Code Examples for org.apache.commons.math.stat.descriptive.DescriptiveStatistics#getStandardDeviation()
The following examples show how to use
org.apache.commons.math.stat.descriptive.DescriptiveStatistics#getStandardDeviation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HeatMapTask.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
private void scale(double[][] peakList) { DescriptiveStatistics stdDevStats = new DescriptiveStatistics(); for (int columns = 0; columns < peakList.length; columns++) { stdDevStats.clear(); for (int row = 0; row < peakList[columns].length; row++) { if (!Double.isInfinite(peakList[columns][row]) && !Double.isNaN(peakList[columns][row])) { stdDevStats.addValue(peakList[columns][row]); } } double stdDev = stdDevStats.getStandardDeviation(); for (int row = 0; row < peakList[columns].length; row++) { if (stdDev != 0) { peakList[columns][row] = peakList[columns][row] / stdDev; } } } }
Example 2
Source File: APARegionStatistics.java From JuiceboxLegacy with MIT License | 6 votes |
public APARegionStatistics(RealMatrix data, int regionWidth) { int max = data.getColumnDimension(); int midPoint = max / 2; double centralVal = data.getEntry(midPoint, midPoint); /** NOTE - indices are inclusive in java, but in python the second index is not inclusive */ peak2mean = centralVal / ((sum(data.getData()) - centralVal) / (data.getColumnDimension() - 1)); double avgUL = mean(data.getSubMatrix(0, regionWidth - 1, 0, regionWidth - 1).getData()); peak2UL = centralVal / avgUL; double avgUR = mean(data.getSubMatrix(0, regionWidth - 1, max - regionWidth, max - 1).getData()); peak2UR = centralVal / avgUR; double avgLL = mean(data.getSubMatrix(max - regionWidth, max - 1, 0, regionWidth - 1).getData()); peak2LL = centralVal / avgLL; double avgLR = mean(data.getSubMatrix(max - regionWidth, max - 1, max - regionWidth, max - 1).getData()); peak2LR = centralVal / avgLR; DescriptiveStatistics yStats = statistics(data.getSubMatrix(max - regionWidth, max - 1, 0, regionWidth - 1).getData()); ZscoreLL = (centralVal - yStats.getMean()) / yStats.getStandardDeviation(); }
Example 3
Source File: HeatMapTask.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
private void scale(double[][] peakList) { DescriptiveStatistics stdDevStats = new DescriptiveStatistics(); for (int columns = 0; columns < peakList.length; columns++) { stdDevStats.clear(); for (int row = 0; row < peakList[columns].length; row++) { if (!Double.isInfinite(peakList[columns][row]) && !Double.isNaN(peakList[columns][row])) { stdDevStats.addValue(peakList[columns][row]); } } double stdDev = stdDevStats.getStandardDeviation(); for (int row = 0; row < peakList[columns].length; row++) { if (stdDev != 0) { peakList[columns][row] = peakList[columns][row] / stdDev; } } } }
Example 4
Source File: APARegionStatistics.java From Juicebox with MIT License | 6 votes |
public APARegionStatistics(RealMatrix data, int regionWidth) { int max = data.getColumnDimension(); int midPoint = max / 2; double centralVal = data.getEntry(midPoint, midPoint); /** NOTE - indices are inclusive in java, but in python the second index is not inclusive */ double mean = (MatrixTools.sum(data.getData()) - centralVal) / (data.getRowDimension() * data.getColumnDimension() - 1); peak2mean = centralVal / mean; double avgUL = mean(data.getSubMatrix(0, regionWidth - 1, 0, regionWidth - 1).getData()); peak2UL = centralVal / avgUL; avgUR = mean(data.getSubMatrix(0, regionWidth - 1, max - regionWidth, max - 1).getData()); peak2UR = centralVal / avgUR; double avgLL = mean(data.getSubMatrix(max - regionWidth, max - 1, 0, regionWidth - 1).getData()); peak2LL = centralVal / avgLL; double avgLR = mean(data.getSubMatrix(max - regionWidth, max - 1, max - regionWidth, max - 1).getData()); peak2LR = centralVal / avgLR; DescriptiveStatistics yStats = statistics(data.getSubMatrix(max - regionWidth, max - 1, 0, regionWidth - 1).getData()); ZscoreLL = (centralVal - yStats.getMean()) / yStats.getStandardDeviation(); }
Example 5
Source File: StatUtils.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Normalize (standardize) the series, so in the end it is having a mean of 0 and a standard deviation of 1. * * @param sample Sample to normalize. * @return normalized (standardized) sample. * @since 2.2 */ public static double[] normalize(final double[] sample) { DescriptiveStatistics stats = new DescriptiveStatistics(); // Add the data from the series to stats for (int i = 0; i < sample.length; i++) { stats.addValue(sample[i]); } // Compute mean and standard deviation double mean = stats.getMean(); double standardDeviation = stats.getStandardDeviation(); // initialize the standardizedSample, which has the same length as the sample double[] standardizedSample = new double[sample.length]; for (int i = 0; i < sample.length; i++) { // z = (x- mean)/standardDeviation standardizedSample[i] = (sample[i] - mean) / standardDeviation; } return standardizedSample; }
Example 6
Source File: StatUtils.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Normalize (standardize) the series, so in the end it is having a mean of 0 and a standard deviation of 1. * * @param sample Sample to normalize. * @return normalized (standardized) sample. * @since 2.2 */ public static double[] normalize(final double[] sample) { DescriptiveStatistics stats = new DescriptiveStatistics(); // Add the data from the series to stats for (int i = 0; i < sample.length; i++) { stats.addValue(sample[i]); } // Compute mean and standard deviation double mean = stats.getMean(); double standardDeviation = stats.getStandardDeviation(); // initialize the standardizedSample, which has the same length as the sample double[] standardizedSample = new double[sample.length]; for (int i = 0; i < sample.length; i++) { // z = (x- mean)/standardDeviation standardizedSample[i] = (sample[i] - mean) / standardDeviation; } return standardizedSample; }
Example 7
Source File: StatUtils.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Normalize (standardize) the series, so in the end it is having a mean of 0 and a standard deviation of 1. * * @param sample Sample to normalize. * @return normalized (standardized) sample. * @since 2.2 */ public static double[] normalize(final double[] sample) { DescriptiveStatistics stats = new DescriptiveStatistics(); // Add the data from the series to stats for (int i = 0; i < sample.length; i++) { stats.addValue(sample[i]); } // Compute mean and standard deviation double mean = stats.getMean(); double standardDeviation = stats.getStandardDeviation(); // initialize the standardizedSample, which has the same length as the sample double[] standardizedSample = new double[sample.length]; for (int i = 0; i < sample.length; i++) { // z = (x- mean)/standardDeviation standardizedSample[i] = (sample[i] - mean) / standardDeviation; } return standardizedSample; }
Example 8
Source File: VectorUtil.java From graphify with Apache License 2.0 | 5 votes |
public static double getFeatureMatchDistribution(GraphDatabaseService db, Long patternId) { Transaction tx = db.beginTx(); Node startNode = db.getNodeById(patternId); // Feature match distribution List<Double> matches = IteratorUtil.asCollection(db.traversalDescription() .depthFirst() .relationships(withName("HAS_CLASS"), Direction.OUTGOING) .evaluator(Evaluators.fromDepth(1)) .evaluator(Evaluators.toDepth(1)) .traverse(startNode) .relationships()) .stream() .map(p -> ((Integer)p.getProperty("matches")).doubleValue()) .collect(Collectors.toList()); tx.success(); tx.close(); double variance = 1.0; if(matches.size() > 1) { Double[] matchArr = matches.toArray(new Double[matches.size()]); // Get the standard deviation DescriptiveStatistics ds = new DescriptiveStatistics(); matches.forEach(m -> ds.addValue(m.doubleValue() / StatUtils.sum(ArrayUtils.toPrimitive(matchArr)))); variance = ds.getStandardDeviation(); } return variance; }