Package com.tdunning.math.stats
Class AgentDigest
- java.lang.Object
-
- com.tdunning.math.stats.TDigest
-
- com.tdunning.math.stats.AbstractTDigest
-
- com.tdunning.math.stats.AgentDigest
-
public class AgentDigest extends com.tdunning.math.stats.AbstractTDigest
NOTE: This is a pruned and modified version ofMergingDigest
. It does not support queries (cdf/quantiles) or the traditional encodings. Maintains a t-digest by collecting new points in a buffer that is then sorted occasionally and merged into a sorted array that contains previously computed centroids. This can be very fast because the cost of sorting and merging is amortized over several insertion. If we keep N centroids total and have the input array is k long, then the amortized cost is something like N/k + log k These costs even out when N/k = log k. Balancing costs is often a good place to start in optimizing an algorithm. For different values of compression factor, the following table shows estimated asymptotic values of N and suggested values of k:Compression N k 50 78 25 100 157 42 200 314 73 - No allocation is required after initialization
- The data structure automatically compresses existing centroids when possible
- No Java object overhead is incurred for centroids since data is kept in primitive arrays
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AgentDigest.AgentDigestMarshaller
Stateless AgentDigest codec for chronicle maps
-
Constructor Summary
Constructors Constructor Description AgentDigest(short compression, long dispatchTimeMillis)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(double x, int w)
void
add(double x, int w, List<Double> history)
void
asBytes(ByteBuffer buf)
void
asSmallBytes(ByteBuffer buf)
int
byteSize()
double
cdf(double x)
int
centroidCount()
Number of centroids of this AgentDigest (does compress if necessary)Collection<com.tdunning.math.stats.Centroid>
centroids()
Not clear to me that this is a good idea, maybe just add the temp points and existing centroids rather then merging first?void
compress()
double
compression()
long
getDispatchTimeMillis()
Time at which this digest should be dispatched to wavefront.double
quantile(double q)
com.tdunning.math.stats.TDigest
recordAllData()
Turns on internal data recording.long
size()
int
smallByteSize()
wavefront.report.Histogram
toHistogram(int duration)
Creates a reporting Histogram from this AgentDigest (marked with the supplied duration).-
Methods inherited from class com.tdunning.math.stats.AbstractTDigest
add, add, createCentroid, decode, encode, interpolate, isRecording, merge, weightedAverage, weightedAverageSorted
-
-
-
-
Method Detail
-
recordAllData
public com.tdunning.math.stats.TDigest recordAllData()
Turns on internal data recording.- Overrides:
recordAllData
in classcom.tdunning.math.stats.AbstractTDigest
-
add
public void add(double x, int w)
- Specified by:
add
in classcom.tdunning.math.stats.TDigest
-
compress
public void compress()
- Specified by:
compress
in classcom.tdunning.math.stats.TDigest
-
size
public long size()
- Specified by:
size
in classcom.tdunning.math.stats.TDigest
-
cdf
public double cdf(double x)
- Specified by:
cdf
in classcom.tdunning.math.stats.TDigest
-
quantile
public double quantile(double q)
- Specified by:
quantile
in classcom.tdunning.math.stats.TDigest
-
centroids
public Collection<com.tdunning.math.stats.Centroid> centroids()
Not clear to me that this is a good idea, maybe just add the temp points and existing centroids rather then merging first?- Specified by:
centroids
in classcom.tdunning.math.stats.TDigest
-
compression
public double compression()
- Specified by:
compression
in classcom.tdunning.math.stats.TDigest
-
byteSize
public int byteSize()
- Specified by:
byteSize
in classcom.tdunning.math.stats.TDigest
-
smallByteSize
public int smallByteSize()
- Specified by:
smallByteSize
in classcom.tdunning.math.stats.TDigest
-
centroidCount
public int centroidCount()
Number of centroids of this AgentDigest (does compress if necessary)
-
toHistogram
public wavefront.report.Histogram toHistogram(int duration)
Creates a reporting Histogram from this AgentDigest (marked with the supplied duration).
-
asBytes
public void asBytes(ByteBuffer buf)
- Specified by:
asBytes
in classcom.tdunning.math.stats.TDigest
-
asSmallBytes
public void asSmallBytes(ByteBuffer buf)
- Specified by:
asSmallBytes
in classcom.tdunning.math.stats.TDigest
-
getDispatchTimeMillis
public long getDispatchTimeMillis()
Time at which this digest should be dispatched to wavefront.
-
-