Package noaa.coastwatch.util
Class Statistics
java.lang.Object
noaa.coastwatch.util.Statistics
The statistics class is a container for various data variable
statistics such as minimum, maximum, mean, standard deviation,
histogram counts, and so on.
- Since:
- 3.1.6
- Author:
- Peter Hollemans
-
Constructor Summary
ConstructorDescriptionStatistics
(DataIterator iter) Creates a new set of statistics.Statistics
(DataIterator iter, boolean saveData) Creates a new set of statistics. -
Method Summary
Modifier and TypeMethodDescriptiondouble
getAdev()
Gets the average deviation from the mean.int
getCount
(double val) Gets the histogram count for a data value.double
getData
(int index) Gets the specified data value.double
getMax()
Gets the maximum data value.double
getMean()
Gets the mean data value.double
Gets the median value of the data.double
getMin()
Gets the minimum data value.double
getNormalizedCount
(double val) Gets the normalized histogram count for a data value.double
getStdev()
Gets the standard deviation from the mean.static Statistics
getTestData
(long seed) Gets a test statistics object with normal distribution.int
getValid()
Gets the total number of valid data values sampled.int
Gets the total number of data values sampled, including invalid data.static void
Tests this class with a very simple data set.toString()
Converts this statistics object to a string.
-
Constructor Details
-
Statistics
Creates a new set of statistics. Using this constructor, the data values are not saved.- Parameters:
iter
- an iterator over all data values required for the statistics calculations.
-
Statistics
Creates a new set of statistics.- Parameters:
iter
- an iterator over all data values required for the statistics calculations.saveData
- the save data flag, true if the data values used in the statistics are to be saved. If the values are saved, they will be available from thegetData(int)
method.
-
-
Method Details
-
getTestData
Gets a test statistics object with normal distribution. -
getValues
public int getValues()Gets the total number of data values sampled, including invalid data. -
getValid
public int getValid()Gets the total number of valid data values sampled. -
getMin
public double getMin()Gets the minimum data value. -
getMax
public double getMax()Gets the maximum data value. -
getMean
public double getMean()Gets the mean data value. -
getStdev
public double getStdev()Gets the standard deviation from the mean. -
getAdev
public double getAdev()Gets the average deviation from the mean. -
getMedian
public double getMedian()Gets the median value of the data. -
getData
public double getData(int index) Gets the specified data value. This is only possible if thesaveData
flag was specified to be true in the constructor.- Parameters:
index
- the data value index.- Returns:
- the data value or
Double.NAN
if no data was saved.
-
getCount
public int getCount(double val) Gets the histogram count for a data value.- Parameters:
val
- the data value for the desired bin.- Returns:
- the histogram bin count or 0 if the data value is out of range.
-
getNormalizedCount
public double getNormalizedCount(double val) Gets the normalized histogram count for a data value.- Parameters:
val
- the data value for the desired bin.- Returns:
- the histogram bin count divided by the count of the maximum bin or 0 if the data value is out of range.
-
toString
Converts this statistics object to a string. -
main
Tests this class with a very simple data set.
-