Java Code Examples for org.apache.commons.math3.stat.StatUtils#max()
The following examples show how to use
org.apache.commons.math3.stat.StatUtils#max() .
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: LikelihoodUtils.java From Drop-seq with MIT License | 6 votes |
/** * Given a set of likelihoods in log10, output 1- the probability of the most largest likelihood [ 1-p]. * @param allLikelihoods a collection of likelihoods * @return 1 - (best like / sum (likes)) */ public double getOneMinusPvalueFromLog10Likelihood (final double [] allLikelihoods) { // we clone the array so we don't change it. double [] likes=allLikelihoods.clone(); Arrays.sort(likes); double maxValue = StatUtils.max(likes); double totalLikelihood=0; double allButBestLikelihood=0; for (int i=0; i<likes.length; i++) { double d = likes[i]; d=d-maxValue; d=Math.pow(10, d); totalLikelihood+=d; if (i!=(likes.length-1)) allButBestLikelihood+=d; } double result = allButBestLikelihood/totalLikelihood; if (result < Double.MIN_VALUE) result = Double.MIN_VALUE; return result; }
Example 2
Source File: LikelihoodUtils.java From Drop-seq with MIT License | 6 votes |
/** * Given a set of likelihoods in log10, output the probability of the most largest likelihood [p]. * @param allLikelihoods * @return */ public double getPvalueFromLog10Likelihood (final double [] allLikelihoods) { //TODO: is it better to clone the array here, or should the class handing off the array do the cloning? double [] likes=allLikelihoods.clone(); Arrays.sort(likes); double maxValue = StatUtils.max(likes); double totalLikelihood=0; for (int i=0; i<likes.length; i++) { double d = likes[i]; d=d-maxValue; d=Math.pow(10, d); totalLikelihood+=d; } double result = 1/totalLikelihood; if (result < Double.MIN_VALUE) result = Double.MIN_VALUE; return result; }
Example 3
Source File: TukeyMeanDifferencePlot.java From tablesaw with Apache License 2.0 | 4 votes |
/** * Returns a figure containing a QQ Plot describing the differences between the distribution of * values in the columns of interest * * @param title A title for the plot * @param measure The measure being compared on the plot (e.g "inches" or "height in inches" * @param xData The data to plot on the x Axis * @param yData The data to plot on the y Axis * @return A quantile plot */ public static Figure create(String title, String measure, double[] xData, double[] yData) { Preconditions.checkArgument(xData.length != 0, "x Data array is empty"); Preconditions.checkArgument(yData.length != 0, "x Data array is empty"); if (xData.length != yData.length) { double[] interpolatedData; if (xData.length < yData.length) { interpolatedData = interpolate(yData, xData.length); yData = interpolatedData; } else { interpolatedData = interpolate(xData, yData.length); xData = interpolatedData; } } Arrays.sort(xData); Arrays.sort(yData); double[] averagePoints = new double[xData.length]; double[] differencePoints = new double[xData.length]; for (int i = 0; i < xData.length; i++) { averagePoints[i] = (xData[i] + yData[i]) / 2.0; differencePoints[i] = (xData[i] - yData[i]); } double xMin = StatUtils.min(xData); double xMax = StatUtils.max(xData); double[] zeroLineX = {xMin, xMax}; double[] zeroLineY = {0, 0}; // Draw the line indicating equal distributions (this is zero in this plot) ScatterTrace trace1 = ScatterTrace.builder(zeroLineX, zeroLineY) .mode(ScatterTrace.Mode.LINE) .name("y = x") .build(); // Draw the actual data points ScatterTrace trace2 = ScatterTrace.builder(averagePoints, differencePoints).name("mean x difference").build(); Layout layout = Layout.builder() .title(title) .xAxis(Axis.builder().title("mean (" + measure + ")").build()) .yAxis(Axis.builder().title("difference (" + measure + ")").build()) .height(700) .width(900) .build(); return new Figure(layout, trace1, trace2); }
Example 4
Source File: AggregateFunctions.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public Double summarize(NumericColumn<?> column) { double[] data = removeMissing(column); return StatUtils.max(data) - StatUtils.min(data); }
Example 5
Source File: AggregateFunctions.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public Double summarize(NumericColumn<?> column) { return StatUtils.max(removeMissing(column)); }
Example 6
Source File: TableSliceGroupTest.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public Double summarize(NumericColumn<?> data) { return StatUtils.max(data.asDoubleArray()) + 1000; }
Example 7
Source File: TukeyMeanDifferencePlot.java From tablesaw with Apache License 2.0 | 4 votes |
/** * Returns a figure containing a QQ Plot describing the differences between the distribution of * values in the columns of interest * * @param title A title for the plot * @param measure The measure being compared on the plot (e.g "inches" or "height in inches" * @param xData The data to plot on the x Axis * @param yData The data to plot on the y Axis * @return A quantile plot */ public static Figure create(String title, String measure, double[] xData, double[] yData) { Preconditions.checkArgument(xData.length != 0, "x Data array is empty"); Preconditions.checkArgument(yData.length != 0, "x Data array is empty"); if (xData.length != yData.length) { double[] interpolatedData; if (xData.length < yData.length) { interpolatedData = interpolate(yData, xData.length); yData = interpolatedData; } else { interpolatedData = interpolate(xData, yData.length); xData = interpolatedData; } } Arrays.sort(xData); Arrays.sort(yData); double[] averagePoints = new double[xData.length]; double[] differencePoints = new double[xData.length]; for (int i = 0; i < xData.length; i++) { averagePoints[i] = (xData[i] + yData[i]) / 2.0; differencePoints[i] = (xData[i] - yData[i]); } double xMin = StatUtils.min(xData); double xMax = StatUtils.max(xData); double[] zeroLineX = {xMin, xMax}; double[] zeroLineY = {0, 0}; // Draw the line indicating equal distributions (this is zero in this plot) ScatterTrace trace1 = ScatterTrace.builder(zeroLineX, zeroLineY) .mode(ScatterTrace.Mode.LINE) .name("y = x") .build(); // Draw the actual data points ScatterTrace trace2 = ScatterTrace.builder(averagePoints, differencePoints).name("mean x difference").build(); Layout layout = Layout.builder() .title(title) .xAxis(Axis.builder().title("mean (" + measure + ")").build()) .yAxis(Axis.builder().title("difference (" + measure + ")").build()) .height(700) .width(900) .build(); return new Figure(layout, trace1, trace2); }
Example 8
Source File: AggregateFunctions.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public Double summarize(NumericColumn<?> column) { double[] data = removeMissing(column); return StatUtils.max(data) - StatUtils.min(data); }
Example 9
Source File: AggregateFunctions.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public Double summarize(NumericColumn<?> column) { return StatUtils.max(removeMissing(column)); }
Example 10
Source File: TableSliceGroupTest.java From tablesaw with Apache License 2.0 | 4 votes |
@Override public Double summarize(NumericColumn<?> data) { return StatUtils.max(data.asDoubleArray()) + 1000; }
Example 11
Source File: KnoxShellTable.java From knox with Apache License 2.0 | 2 votes |
/** * Calculates the max of specified column * @param colName the column for which the max will be calculated * @return max */ public double max(String colName) { return StatUtils.max(toDoubleArray(colName)); }