public final class LinearDistribution extends Distribution implements java.io.Serializable, java.lang.Comparable<LinearDistribution>
lquantize()
action. Aggregated values fall into consecutive ranges
bounded by the step parameter of the lquantize()
action.
Each range, known as a bucket, begins at the lquantize()
lower bound, or base, plus a multiple of the lquantize()
step, unless it is the first bucket, which is the frequency of all
aggregated values less than the base. The last bucket counts all
aggregated values greater than or equal to the lquantize()
upper bound. For example
@ = lquantize(n, 0, 100, 10);
results in a distribution with a base of 0, an upper bound of 100,
and a step of 10. It has twelve buckets starting with n < 0
and ending with n >= 100
. The buckets in between are 0 .. 9
, 10 .. 19
, etc.
Immutable. Supports persistence using XMLEncoder
.
LogDistribution
,
Aggregation
,
Serialized FormDistribution.Bucket
Constructor and Description |
---|
LinearDistribution(long lowerBound,
long bucketStep,
java.util.List<Distribution.Bucket> frequencies)
Creates a linear distribution with the given base, step, and
frequencies.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(LinearDistribution d)
Compares the
double values of getValue() for
overall magnitude, and if those are equal, compares the
frequencies at zero if the distributions include a bucket whose
range has a minimum of zero. |
long |
getBase()
Gets the lower bound of this distribution.
|
long |
getStep()
Gets the difference between the lower bounds of consecutive
buckets after the first.
|
java.lang.Number |
getValue()
Gets the numeric value of this distribution used to compare
distributions by overall magnitude, defined as the sum total of
each bucket's frequency times the minimum of its range.
|
java.lang.String |
toString()
Gets a string representation of this linear distribution useful
for logging and not intended for display.
|
asList, equals, get, getBuckets, getDisplayRange, getTotal, hashCode, iterator, size
public LinearDistribution(long lowerBound, long bucketStep, java.util.List<Distribution.Bucket> frequencies)
lowerBound
- also known as the base; the minimum of
the second bucket in this distribution (the first bucket contains
the frequency of everything lower than the base)bucketStep
- the distance between the lower bound of one
bucket and the lower bound of the next consecutive bucket
(excluding the first bucket)frequencies
- list of frequencies in each bucket rangejava.lang.NullPointerException
- if frequencies
is null
java.lang.IllegalArgumentException
- if the given step is less than
one, or if any bucket does not have the expected range
(consecutive steps)public long getBase()
public long getStep()
public java.lang.Number getValue()
Distribution
getValue
in interface AggregationValue
getValue
in class Distribution
public int compareTo(LinearDistribution d)
double
values of getValue()
for
overall magnitude, and if those are equal, compares the
frequencies at zero if the distributions include a bucket whose
range has a minimum of zero.compareTo
in interface java.lang.Comparable<LinearDistribution>
public java.lang.String toString()
class-name[property1 = value1, property2 = value2]
toString
in class Distribution