public class HistogramStream extends OnlineComputation
Modifier and Type | Field and Description |
---|---|
protected java.util.List<StatisticsStream> |
bins
Each bin in the histogram, indexed by time.
|
protected int |
binWidth
The maximum number of observations in each bin.
|
protected int |
count
The number of total observations.
|
protected StatisticsStream |
current
The current statistics stream we are updating.
|
Modifier | Constructor and Description |
---|---|
|
HistogramStream(HistogramStream other)
Construct a new copy of the given histogram.
|
|
HistogramStream(int binWidth)
Construct a new histogram stream which splits up every observation in different bins, ordered by time.
|
protected |
HistogramStream(java.util.List<StatisticsStream> bins,
StatisticsStream current,
int binWidth)
Construct a new histogram stream.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkOverflow()
See if the current bin has overflowed.
|
HistogramStream |
copy()
Construct a copy of the current online computation.
|
com.google.common.collect.ImmutableList<StatisticsStream> |
getBins()
Retrieve an immutable view of every bin in the histogram.
|
int |
getCount()
Retrieve the number of observations.
|
StatisticsStream |
getTotal()
Retrieve the total statistics of every bin in the histogram.
|
void |
observe(double value)
Observe a value.
|
synchronizedComputation
protected java.util.List<StatisticsStream> bins
protected StatisticsStream current
protected int binWidth
protected int count
public HistogramStream(int binWidth)
binWidth
- - maximum number of observations in each bin.public HistogramStream(HistogramStream other)
other
- - the histogram to copy.protected HistogramStream(java.util.List<StatisticsStream> bins, StatisticsStream current, int binWidth)
bins
- - list of bins.current
- - the current selected bin. This will be added to the list if it is not already present.binWidth
- - the desired number of observations in each bin.public HistogramStream copy()
OnlineComputation
copy
in class OnlineComputation
public com.google.common.collect.ImmutableList<StatisticsStream> getBins()
public void observe(double value)
OnlineComputation
observe
in class OnlineComputation
value
- - the observed value.protected void checkOverflow()
public StatisticsStream getTotal()
This method is not thread safe.
public int getCount()
OnlineComputation
getCount
in class OnlineComputation