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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddValue(double val) Add another value; NaN values are counted but do not contribute to the statistics.doublegetMax()Get the maximum non-NaN value added.doublegetMean()Get the mean of all non-NaN values that were added.doublegetMin()Get the minimum non-NaN value added.longGet count of the number of NaN values added.doublegetRange()Get the range, i.e.doubleGet the standard deviation of all non-NaN values that were added.doublegetSum()Get the sum of all non-NaN values that were added.doubleGet the variance of all non-NaN values that were added.longsize()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
-