Template Class tdigest

Nested Relationships

Nested Types

Class Documentation

template<typename Values = float, typename Weight = unsigned>
class tdigest

Public Functions

explicit tdigest(size_t size)
tdigest() = delete
tdigest(const tdigest&)
tdigest(tdigest&&) noexcept
tdigest &operator=(tdigest)
inline void insert(Values value)

Inserts the given value into the t-digest input buffer. Assumes a weight of 1 for the sample. If this operation fills the input buffer an automatic merge() operation is triggered.

Parameters:

value – value to insert

inline void insert(Values value, Weight weight)

Inserts the given value with the given weight into the t-digest input buffer. If this operation fills the input buffer an automatic merge() operation is triggered.

Parameters:
  • value – value to insert

  • weight – weight associated with the provided value

void insert(const tdigest<Values, Weight> &src)

Insert and merge an existing t-digest. Assumes source t-digest is not receiving new data.

Parameters:

src – source t-digest to copy values from

void reset()

Reset internal state of the t-digest.

Clears t-digest, incoming data buffer, and resets min/max values.

std::vector<std::pair<Values, Weight>> get() const

Retrieve contents of the t-digest.

Returns:

list of <value, weight> pairs sorted by value in ascending order.

void merge()

Merge incoming data into the t-digest.

Based on the equivalent function in the reference implementation available here: https://github.com/tdunning/t-digest

double cumulative_distribution(Values x) const

Retrieve the probability that a random data point in the digest is less than or equal to x.

Based on the equivalent function in the reference implementation available here: https://github.com/tdunning/t-digest

Parameters:

x – value of interest

Returns:

a value between [0, 1]

double quantile(double p) const

Retrieve the value such that p percent of all data points or less than or equal to that value.

Based on the equivalent function in the reference implementation available here: https://github.com/tdunning/t-digest

Parameters:

p – percentile of interest; valid input between [0.0, 100.0]

Returns:

a value from the dataset that satisfies the above condition

inline size_t centroid_count() const

Return number of centroids in the t-digest

inline size_t size() const

Retrieve the number of merged data points in the t-digest

Returns:

the total weight of all data

inline Values max() const

Retrieve maximum value seen by this t-digest. Value is cleared by reset().

Returns:

maximum value seen by this t-digest.

inline Values min() const

Retrieve minimum value seen by this t-digest. Value is cleared by reset().

Returns:

minimum value seen by this t-digest.