public class ArrayOps
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.text.DecimalFormat |
decimalDF |
static java.text.DecimalFormat |
integerDF |
Constructor and Description |
---|
ArrayOps() |
Modifier and Type | Method and Description |
---|---|
static double |
geoMean(double[] arr)
Returns the geometric mean value in the array.
|
static double |
max(double[] arr)
Returns the largest value in the array.
|
static double |
mean(double[] arr)
Returns the mean value in the array.
|
static double |
median(double[] arr)
Returns the median value in the array.
|
static double |
min(double[] arr)
Returns the smallest value in the array.
|
static double |
sum(double[] arr)
Returns the sum of the values in the array.
|
static java.lang.String |
toString(double[] data)
Converts an array to a string representation with a specified number of decimal places
|
static double |
var(double[] arr,
double mean)
Returns the variance of the values in the array.
|
static double |
weightedMean(double[] arr,
double[] weights)
Returns the mean value in the array.
|
static double |
weightedVar(double[] arr,
double[] weights,
double wMean)
Returns the weighted variance of the values in the array.
|
public static final java.text.DecimalFormat decimalDF
public static final java.text.DecimalFormat integerDF
public static double max(double[] arr)
arr
- The array.public static double min(double[] arr)
arr
- The array.public static double mean(double[] arr)
arr
- The array.public static double sum(double[] arr)
arr
- The array.public static double weightedMean(double[] arr, double[] weights)
arr
- The array.weights
- An array of non-negative weights, the same length as arr
.public static double geoMean(double[] arr)
arr
- The array.public static double median(double[] arr)
NaN
and Infinity
are
handled in the same way as in the Java Arrays.sort
method. If there are an
even number of values in the array, the method returns the mean of the middle two values.arr
- The array.public static double var(double[] arr, double mean)
arr
- The array.mean
- the mean value.public static double weightedVar(double[] arr, double[] weights, double wMean)
arr
- The array.wMean
- the weighted mean value.public static java.lang.String toString(double[] data)