SimpleStats

public class SimpleStats
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.SimpleStats


A small utility class that calculates a few statistical measures given a numerical dataset. The values are stored internally as Doubles.

Summary

Public constructors

SimpleStats()

Public methods

void add(double meas)

Add a measurement to the dataset.

void addAll(Collection<? extends Double> c)

Add a number of measurements to the dataset.

List<Double> getData()

Retrieve the dataset.

boolean isEmpty()

Check if the dataset is empty.

Double max()

Return the maximum value in the dataset, or null if the dataset is empty.

Double mean()

Calculate and return the mean of the dataset, or null if the dataset is empty.

Double meanOverOneStandardDeviationRange()

return the average value of the samples that are within one stdev e.g 2.55 50.3 50.4 48.5 50.1 29.8 30 46 48 49 average: 40.45, stdev: 15.54 average of the values within one stdev is: 44.67

Double median()

Calculate and return the median of the dataset, or null if the dataset is empty.

Double min()

Return the minimum value in the dataset, or null if the dataset is empty.

int size()

Check how many elements are in the dataset.

Double stdev()

Return the standard deviation of the dataset, or null if the dataset is empty.

Public constructors

SimpleStats

public SimpleStats ()

Public methods

add

public void add (double meas)

Add a measurement to the dataset.

Parameters
meas double

addAll

public void addAll (Collection<? extends Double> c)

Add a number of measurements to the dataset.

Parameters
c Collection

Throws
NullPointerException if the collection contains any null elements

getData

public List<Double> getData ()

Retrieve the dataset.

Returns
List<Double>

isEmpty

public boolean isEmpty ()

Check if the dataset is empty.

Returns
boolean

max

public Double max ()

Return the maximum value in the dataset, or null if the dataset is empty.

Returns
Double

mean

public Double mean ()

Calculate and return the mean of the dataset, or null if the dataset is empty.

Returns
Double

meanOverOneStandardDeviationRange

public Double meanOverOneStandardDeviationRange ()

return the average value of the samples that are within one stdev e.g 2.55 50.3 50.4 48.5 50.1 29.8 30 46 48 49 average: 40.45, stdev: 15.54 average of the values within one stdev is: 44.67

Returns
Double

median

public Double median ()

Calculate and return the median of the dataset, or null if the dataset is empty.

Returns
Double

min

public Double min ()

Return the minimum value in the dataset, or null if the dataset is empty.

Returns
Double

size

public int size ()

Check how many elements are in the dataset.

Returns
int

stdev

public Double stdev ()

Return the standard deviation of the dataset, or null if the dataset is empty.

Note that this method calculates the population standard deviation, not the sample standard deviation. That is, it assumes that the dataset is entirely contained in the SimpleStats instance.

Returns
Double