public final class Distribution extends Object
The bucket boundaries for that histogram are described by BucketBoundaries, which
defines BucketBoundaries.getBoundaries().size() + 1 (= N) buckets.
The boundaries for bucket index i are:
i.e. an underflow bucket (number 0), zero or more finite buckets (1 through N - 2, and an overflow bucket (N - 1), with inclusive lower bounds and exclusive upper bounds.
Note: If N = 1, there are no finite buckets and the single bucket is both the overflow and underflow bucket. TODO(songya): needs to determine whether N = 1 is valid. (Currently we don't allow N = 1.)
Although not forbidden, it is generally a bad idea to include non-finite values (infinities or
NaNs) in the population of values, as this will render the mean meaningless.
| Modifier and Type | Class and Description |
|---|---|
static class |
Distribution.Range
Describes a range of population values.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(double value)
Put a new value into the Distribution.
|
static Distribution |
create()
Constructs a new, empty
Distribution. |
static Distribution |
create(BucketBoundaries bucketBoundaries)
Constructs a new
Distribution with specified bucketBoundaryList. |
List<Long> |
getBucketCounts()
A Distribution may optionally contain a histogram of the values in the population.
|
long |
getCount()
The number of values in the population.
|
double |
getMean()
The arithmetic mean of the values in the population.
|
Distribution.Range |
getRange()
The range of the population values.
|
double |
getSum()
The sum of the values in the population.
|
public static final Distribution create()
Distribution.Distribution.public static final Distribution create(BucketBoundaries bucketBoundaries)
Distribution with specified bucketBoundaryList.bucketBoundaries - the boundaries for the buckets in the underlying Distribution.Distribution with the specified boundaries.public long getCount()
public double getMean()
getCount() is zero then this
value will be NaN.public double getSum()
getCount() is zero then this value must
also be zero.public Distribution.Range getRange()
getCount() is zero then this returned range is
implementation-dependent.@Nullable public List<Long> getBucketCounts()
getBucketCounts() as counts of values that fall into one of a
sequence of non-overlapping buckets, described by BucketBoundaries.
The sum of the values in getBucketCounts() must equal the value in
getCount().
Bucket counts are given in order under the numbering scheme described above (the underflow bucket has number 0; the finite buckets, if any, have numbers 1 through N-2; the overflow bucket has number N-1).
The size of getBucketCounts() must be no greater than N as defined in BucketBoundaries.
Any suffix of trailing buckets containing only zero may be omitted.
getBucketCounts() will return null iff the associated BucketBoundaries
is null.
public void add(double value)
value - new value to be added to population