Java Code Examples for org.apache.commons.math.stat.descriptive.DescriptiveStatistics#getMean()
The following examples show how to use
org.apache.commons.math.stat.descriptive.DescriptiveStatistics#getMean() .
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: 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 2
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 3
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 4
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 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: ExpressionFigure.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
/** * * @param title * @param _siList * @param variable */ public void setSurvivalInfo(ArrayList<String> title, ArrayList<SurvivalInfo> _siList, String variable) { this.siList = new ArrayList<SurvivalInfo>(); this.title = title; this.variable = variable; minX = 0.0; maxX = (double) _siList.size(); minY = 0.0; maxY = null; DescriptiveStatistics ds = new DescriptiveStatistics(); for (SurvivalInfo si : _siList) { this.siList.add(si); String v = si.getOriginalMetaData(variable); Double value = Double.parseDouble(v); ds.addValue(value); if (maxTime == null || maxTime < si.getTime()) { maxTime = si.getTime(); } } SurvivalInfoValueComparator sivc = new SurvivalInfoValueComparator(variable); Collections.sort(this.siList, sivc); mean = ds.getMean(); minY = ds.getMin(); maxY = ds.getMax(); minY = (double) Math.floor(minY); maxY = (double) Math.ceil(maxY); this.repaint(); }