Package qupath.lib.analysis.stats
Class RunningStatistics
java.lang.Object
qupath.lib.analysis.stats.RunningStatistics
Helper class for computing basic statistics from values as they are added.
This is useful e.g. when iterating through pixels, computing statistics from masked/labelled values.
Warning! This maintains a sum as a double - for many pixels and/or 16-bit data this may lead to imprecision (although for small regions, and especially optical densities having low values, it should be fine).
A warning is logged for particularly large values.
- Author:
- Pete Bankhead
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addValue
(double val) Add another value; NaN values are counted but do not contribute to the statistics.double
getMax()
Get the maximum non-NaN value added.double
getMean()
Get the mean of all non-NaN values that were added.double
getMin()
Get the minimum non-NaN value added.long
Get count of the number of NaN values added.double
getRange()
Get the range, i.e.double
Get the standard deviation of all non-NaN values that were added.double
getSum()
Get the sum of all non-NaN values that were added.double
Get the variance of all non-NaN values that were added.long
size()
Get count of the number of non-NaN values added.toString()
-
Field Details
-
size
protected long size
-
-
Constructor Details
-
RunningStatistics
public RunningStatistics()Default constructor.
-
-
Method Details
-
size
public long size()Get count of the number of non-NaN values added.- Returns:
- See Also:
-
addValue
public void addValue(double val) Add another value; NaN values are counted but do not contribute to the statistics.- Parameters:
val
-- See Also:
-
getNumNaNs
public long getNumNaNs()Get count of the number of NaN values added.- Returns:
- See Also:
-
getSum
public double getSum()Get the sum of all non-NaN values that were added.- Returns:
-
getMean
public double getMean()Get the mean of all non-NaN values that were added.- Returns:
-
getVariance
public double getVariance()Get the variance of all non-NaN values that were added.- Returns:
-
getStdDev
public double getStdDev()Get the standard deviation of all non-NaN values that were added.- Returns:
-
getMin
public double getMin()Get the minimum non-NaN value added.- Returns:
- the minimum value, or NaN if no values are available.
-
getMax
public double getMax()Get the maximum non-NaN value added.- Returns:
- the maximum value, or NaN if no values are available.
-
getRange
public double getRange()Get the range, i.e. maximum - minimum values.- Returns:
-
toString
-