Package org.eclipse.imagen.media.numeric
Class SampleStats
Object
SampleStats
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
- Author:
- Michael Bedward, Daniele Romagnoli, GeoSolutions S.A.S.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleReturn the maximum of the given values.static doubleReturn the mean of the given values.static doubleCalculates the median of the given values.static doubleCalculates the minimum of the given values.static doubleCalculates the empirical mode (highest frequency value) of the given values.static doubleCalculates the range (max - min) of a set of values.static doubleCalculates sample standard deviation.static doubleCalculates the sum of the values.static doubleCalculates 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
-
Constructor Details
-
SampleStats
public SampleStats()
-
-
Method Details
-
max
Return the maximum of the given values.- Parameters:
values- sample valuesignoreNaN- specifies whether to ignore NaN values- Returns:
- max value or Double.NaN if the sample is empty
-
mean
Return the mean of the given values.- Parameters:
values- sample valuesignoreNaN- specifies whether to ignore NaN values- Returns:
- mean value or Double.NaN if the sample is empty
-
min
Calculates the minimum of the given values.- Parameters:
values- sample valuesignoreNaN- specifies whether to ignore NaN values- Returns:
- min value or Double.NaN if the sample is empty
-
median
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
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:- for an odd number of tied values, return their median
- for an even number of tied values, return the value below the mid-point of the sorted list of tied values
- Parameters:
values- sample valuesignoreNaN- specifies whether to ignore NaN values- Returns:
- calculated mode or Double.NaN if the sample is empty
-
range
Calculates the range (max - min) of a set of values.- Parameters:
values- sample valuesignoreNaN- specifies whether to ignore NaN values- Returns:
- the range or Double.NaN if the set is empty
-
variance
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 valuesignoreNaN- specifies whether to ignore NaN values- Returns:
- sample variance
-
sdev
Calculates sample standard deviation. This is a convenience method that calls variance(Double[], boolean) and returns the square-root of the result- Parameters:
values- sample valuesignoreNaN- specifies whether to ignore NaN values- Returns:
- sample standard deviation as a double
-
sum
Calculates the sum of the values.- Parameters:
values- sample valuesignoreNaN- specifies whether to ignore NaN values- Returns:
- sum of the values
-