Package com.tdunning.math.stats
Class AbstractTDigest
java.lang.Object
com.tdunning.math.stats.TDigest
com.tdunning.math.stats.AbstractTDigest
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AVLTreeDigest
,MergingDigest
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double x) Adds a sample to a histogram.(package private) abstract void
void
Add all of the centroids of another TDigest to this one.protected Centroid
createCentroid
(double mean, int id) (package private) static int
decode
(ByteBuffer buf) (package private) static void
encode
(ByteBuffer buf, int n) (package private) static double
interpolate
(double x, double x0, double x1) boolean
(package private) 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.Sets up so that all centroids will record all data assigned to them.(package private) static double
weightedAverage
(double x1, double w1, double x2, double w2) Same asweightedAverageSorted(double, double, double, double)
but flips the order of the variables ifx2
is greater thanx1
.private static double
weightedAverageSorted
(double x1, double w1, double x2, double w2) Compute the weighted average betweenx1
with a weight ofw1
andx2
with 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
-
Field Details
-
gen
-
recordAllData
boolean recordAllData
-
-
Constructor Details
-
AbstractTDigest
public AbstractTDigest()
-
-
Method Details
-
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 ifx2
is greater thanx1
. -
weightedAverageSorted
private static double weightedAverageSorted(double x1, double w1, double x2, double w2) Compute the weighted average betweenx1
with a weight ofw1
andx2
with a weight ofw2
. This expectsx1
to be less than or equal tox2
and is guaranteed to return a number betweenx1
andx2
. -
interpolate
static double interpolate(double x, double x0, double x1) -
encode
-
decode
-
add
-
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
Sets up so that all centroids will record all data assigned to them. For testing only, really.- Specified by:
recordAllData
in classTDigest
- Returns:
- This TDigest so that configurations can be done in fluent style.
-
isRecording
public boolean isRecording()- Specified by:
isRecording
in classTDigest
-
add
public void add(double x) Adds a sample to a histogram. -
add
Description copied from class:TDigest
Add all of the centroids of another TDigest to this one. -
createCentroid
-