org.openimaj.math.util

## Class DoubleArrayStatsUtils

• ```public class DoubleArrayStatsUtils
extends Object```
Some basic statistical operations on double arrays
Author:
Sina Samangooei (ss@ecs.soton.ac.uk)
• ### Constructor Summary

Constructors
Constructor and Description
`DoubleArrayStatsUtils()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double` `mean(double[] arr)`
Find the mean of a single dimensional double array.
`static double` `mean(double[][] arr)`
Calculate the mean of a two dimensional double array.
`static double` `median(double[] arr)`
Calculate the median of the given array.
`static double` ```median(double[] arr, int start, int stop)```
Calculate the median of the given sub-array.
`static double` `std(double[] arr)`
Calculate the sample standard deviation of a 1D array.
`static double` `std(double[][] arr)`
Calculate the sample standard deviation of a 2D array.
`static double` `sum(double[] arr)`
Calculate the sum of a 1D array.
`static double` `sum(double[][] arr)`
Calculate the sum of a 2D array.
`static double` `sumAbs(double[] arr)`
Calculate the sum the absolute values of a 1D array.
`static double` `sumAbs(double[][] arr)`
Calculate the sum of the absolute values of a 2D array.
`static double` `sumSq(double[] arr)`
Calculate the sum the squared values of a 1D array.
`static double` `sumSq(double[][] arr)`
Calculate the sum of the squared values of a 2D array.
`static double` `var(double[] arr)`
Calculate the sample variance of a one dimensional double array.
`static double` `var(double[][] arr)`
Calculate the sample variance of a one dimensional double array.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### DoubleArrayStatsUtils

`public DoubleArrayStatsUtils()`
• ### Method Detail

• #### mean

`public static double mean(double[] arr)`
Find the mean of a single dimensional double array. returns 0 if the array is empty.
Parameters:
`arr` -
Returns:
the mean
• #### mean

`public static double mean(double[][] arr)`
Calculate the mean of a two dimensional double array. returns 0 if the array is empty.
Parameters:
`arr` -
Returns:
the mean
• #### var

`public static double var(double[] arr)`
Calculate the sample variance of a one dimensional double array. If the length of the array is less than 2, variance is 0.
Parameters:
`arr` -
Returns:
the variance
• #### var

`public static double var(double[][] arr)`
Calculate the sample variance of a one dimensional double array. If the length of the array is less than 2, variance is 0.
Parameters:
`arr` -
Returns:
the variance
• #### std

`public static double std(double[][] arr)`
Calculate the sample standard deviation of a 2D array. Calls `var(double[][])` and does a Math.sqrt.
Parameters:
`arr` -
Returns:
the standard deviation
• #### std

`public static double std(double[] arr)`
Calculate the sample standard deviation of a 1D array. Calls `var(double[])` and does a Math.sqrt.
Parameters:
`arr` -
Returns:
the standard deviation
• #### sum

`public static double sum(double[][] arr)`
Calculate the sum of a 2D array.
Parameters:
`arr` -
Returns:
the sum
• #### sum

`public static double sum(double[] arr)`
Calculate the sum of a 1D array.
Parameters:
`arr` -
Returns:
the sum
• #### sumSq

`public static double sumSq(double[][] arr)`
Calculate the sum of the squared values of a 2D array.
Parameters:
`arr` -
Returns:
sum of squares
• #### sumSq

`public static double sumSq(double[] arr)`
Calculate the sum the squared values of a 1D array.
Parameters:
`arr` -
Returns:
sum of squares
• #### sumAbs

`public static double sumAbs(double[][] arr)`
Calculate the sum of the absolute values of a 2D array.
Parameters:
`arr` -
Returns:
the sum absolute values
• #### sumAbs

`public static double sumAbs(double[] arr)`
Calculate the sum the absolute values of a 1D array.
Parameters:
`arr` -
Returns:
the sum absolute values
• #### median

`public static double median(double[] arr)`
Calculate the median of the given array. Uses the quick select algorithm (`ArrayUtils.quickSelect(double[], int)`).
Parameters:
`arr` - the array
Returns:
the median value
• #### median

```public static double median(double[] arr,
int start,
int stop)```
Calculate the median of the given sub-array. Uses the quick select algorithm (`ArrayUtils.quickSelect(double[], int, int, int)`).
Parameters:
`arr` - the array
`start` - starting point in the array (inclusive)
`stop` - stopping point in the array (exclusive)
Returns:
the median value