org.jaitools.numeric
Class SampleStats

java.lang.Object
  extended by org.jaitools.numeric.SampleStats

public class SampleStats
extends Object

A collection of static methods to calculate summary statistics for a sample of double-valued data. This class is used by both Jiffle and the KernelStats operator.

Since:
1.0
Version:
$Id$
Author:
Michael Bedward, Daniele Romagnoli, GeoSolutions S.A.S.

Constructor Summary
SampleStats()
           
 
Method Summary
static double max(Double[] values, boolean ignoreNaN)
          Return the maximum of the given values.
static double mean(Double[] values, boolean ignoreNaN)
          Return the mean of the given values.
static double median(Double[] values, boolean ignoreNaN)
          Calculates the median of the given values.
static double min(Double[] values, boolean ignoreNaN)
          Calculates the minimum of the given values.
static double mode(Double[] values, boolean ignoreNaN)
          Calculates the empirical mode (highest frequency value) of the given values.
static double range(Double[] values, boolean ignoreNaN)
          Calculates the range (max - min) of a set of values.
static double sdev(Double[] values, boolean ignoreNaN)
          Calculates sample standard deviation.
static double sum(Double[] values, boolean ignoreNaN)
          Calculates the sum of the values.
static double variance(Double[] values, boolean ignoreNaN)
          Calculates sample variance using the running sample algorithm of Welford (1962) described by Knuth in The Art of Computer Programming (3rd ed) Vol.2 p.232
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SampleStats

public SampleStats()
Method Detail

max

public static double max(Double[] values,
                         boolean ignoreNaN)
Return the maximum of the given values.

Parameters:
values - sample values
ignoreNaN - specifies whether to ignore NaN values
Returns:
max value or Double.NaN if the sample is empty

mean

public static double mean(Double[] values,
                          boolean ignoreNaN)
Return the mean of the given values.

Parameters:
values - sample values
ignoreNaN - specifies whether to ignore NaN values
Returns:
mean value or Double.NaN if the sample is empty

min

public static double min(Double[] values,
                         boolean ignoreNaN)
Calculates the minimum of the given values.

Parameters:
values - sample values
ignoreNaN - specifies whether to ignore NaN values
Returns:
min value or Double.NaN if the sample is empty

median

public static double median(Double[] values,
                            boolean ignoreNaN)
Calculates the median of the given values. For a sample with an odd number of elements the median is the mid-point value of the sorted sample. For an even number of elements it is the mean of the two values on either side of the mid-point.

Parameters:
values - sample values (need not be pre-sorted)
ignoreNaN - specifies whether to ignore NaN values
Returns:
median value or Double.NaN if the sample is empty

mode

public static double mode(Double[] values,
                          boolean ignoreNaN)
Calculates the empirical mode (highest frequency value) of the given values. Double.NaN values are ignored. If more than one data value occurs with maximum frequency the following tie-break rules are used: This ensures that the calculated mode occurs in the sample data. Whether or not the mode is meaningful for the sample is up to the user !

Parameters:
values - sample values
ignoreNaN - specifies whether to ignore NaN values
Returns:
calculated mode or Double.NaN if the sample is empty

range

public static double range(Double[] values,
                           boolean ignoreNaN)
Calculates the range (max - min) of a set of values.

Parameters:
values - sample values
ignoreNaN - specifies whether to ignore NaN values
Returns:
the range or Double.NaN if the set is empty

variance

public static double variance(Double[] values,
                              boolean ignoreNaN)
Calculates sample variance using the running sample algorithm of Welford (1962) described by Knuth in The Art of Computer Programming (3rd ed) Vol.2 p.232

Parameters:
values - sample values
ignoreNaN - specifies whether to ignore NaN values
Returns:
sample variance

sdev

public static double sdev(Double[] values,
                          boolean ignoreNaN)
Calculates sample standard deviation. This is a convenience method that calls variance(java.lang.Double[], boolean) and returns the square-root of the result

Parameters:
values - sample values
ignoreNaN - specifies whether to ignore NaN values
Returns:
sample standard deviation as a double

sum

public static double sum(Double[] values,
                         boolean ignoreNaN)
Calculates the sum of the values.

Parameters:
values - sample values
ignoreNaN - specifies whether to ignore NaN values
Returns:
sum of the values


Copyright © 2009-2013. All Rights Reserved.