Package com.tdunning.math.stats
Class AbstractTDigest
- java.lang.Object
-
- com.tdunning.math.stats.TDigest
-
- com.tdunning.math.stats.AbstractTDigest
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
AVLTreeDigest,MergingDigest
public abstract class AbstractTDigest extends TDigest
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.Randomgen(package private) booleanrecordAllData
-
Constructor Summary
Constructors Constructor Description AbstractTDigest()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(double x)Adds a sample to a histogram.(package private) abstract voidadd(double x, int w, Centroid base)voidadd(TDigest other)Add all of the centroids of another TDigest to this one.protected CentroidcreateCentroid(double mean, int id)(package private) static intdecode(java.nio.ByteBuffer buf)(package private) static voidencode(java.nio.ByteBuffer buf, int n)(package private) static doubleinterpolate(double x, double x0, double x1)booleanisRecording()(package private) static doublequantile(double index, double previousIndex, double nextIndex, double previousMean, double nextMean)Computes an interpolated value of a quantile that is between two centroids.TDigestrecordAllData()Sets up so that all centroids will record all data assigned to them.(package private) static doubleweightedAverage(double x1, double w1, double x2, double w2)Same asweightedAverageSorted(double, double, double, double)but flips the order of the variables ifx2is greater thanx1.private static doubleweightedAverageSorted(double x1, double w1, double x2, double w2)Compute the weighted average betweenx1with a weight ofw1andx2with a weight ofw2.-
Methods inherited from class com.tdunning.math.stats.TDigest
add, add, asBytes, asSmallBytes, byteSize, cdf, centroidCount, centroids, checkValue, compress, compression, createAvlTreeDigest, createDigest, createMergingDigest, getMax, getMin, quantile, setMinMax, size, smallByteSize
-
-
-
-
Method Detail
-
weightedAverage
static double weightedAverage(double x1, double w1, double x2, double w2)Same asweightedAverageSorted(double, double, double, double)but flips the order of the variables ifx2is greater thanx1.
-
weightedAverageSorted
private static double weightedAverageSorted(double x1, double w1, double x2, double w2)Compute the weighted average betweenx1with a weight ofw1andx2with a weight ofw2. This expectsx1to be less than or equal tox2and is guaranteed to return a number betweenx1andx2.
-
interpolate
static double interpolate(double x, double x0, double x1)
-
encode
static void encode(java.nio.ByteBuffer buf, int n)
-
decode
static int decode(java.nio.ByteBuffer buf)
-
add
abstract void add(double x, int w, Centroid base)
-
quantile
static double quantile(double index, double previousIndex, double nextIndex, double previousMean, double nextMean)Computes an interpolated value of a quantile that is between two centroids. Index is the quantile desired multiplied by the total number of samples - 1.- Parameters:
index- Denormalized quantile desiredpreviousIndex- The denormalized quantile corresponding to the center of the previous centroid.nextIndex- The denormalized quantile corresponding to the center of the following centroid.previousMean- The mean of the previous centroid.nextMean- The mean of the following centroid.- Returns:
- The interpolated mean.
-
recordAllData
public TDigest recordAllData()
Sets up so that all centroids will record all data assigned to them. For testing only, really.- Specified by:
recordAllDatain classTDigest- Returns:
- This TDigest so that configurations can be done in fluent style.
-
isRecording
public boolean isRecording()
- Specified by:
isRecordingin classTDigest
-
add
public void add(double x)
Adds a sample to a histogram.
-
add
public void add(TDigest other)
Description copied from class:TDigestAdd all of the centroids of another TDigest to this one.
-
createCentroid
protected Centroid createCentroid(double mean, int id)
-
-