datasketches-cpp
|
Sorted view for quantiles sketches (REQ, KLL and Quantiles) More...
#include <quantiles_sorted_view.hpp>
Public Types | |
using | Entry = typename std::conditional< std::is_arithmetic< T >::value, std::pair< T, uint64_t >, std::pair< const T *, uint64_t > >::type |
Entry type. | |
using | quantile_return_type = typename std::conditional< std::is_arithmetic< T >::value, T, const T & >::type |
Quantile return type. More... | |
Public Member Functions | |
const_iterator | begin () const |
Iterator pointing to the first entry in the view. More... | |
const_iterator | end () const |
Iterator pointing to the past-the-end entry in the view. More... | |
size_t | size () const |
double | get_rank (const T &item, bool inclusive=true) const |
Returns an approximation to the normalized rank of the given item. More... | |
quantile_return_type | get_quantile (double rank, bool inclusive=true) const |
Returns an item from the sketch that is the best approximation to an item from the original stream with the given normalized rank. More... | |
vector_double | get_CDF (const T *split_points, uint32_t size, bool inclusive=true) const |
Returns an approximation to the Cumulative Distribution Function (CDF), which is the cumulative analog of the PMF, of the input stream given a set of split points (items). More... | |
vector_double | get_PMF (const T *split_points, uint32_t size, bool inclusive=true) const |
Returns an approximation to the Probability Mass Function (PMF) of the input stream given a set of split points (items). More... | |
Sorted view for quantiles sketches (REQ, KLL and Quantiles)
using quantile_return_type = typename std::conditional<std::is_arithmetic<T>::value, T, const T&>::type |
Quantile return type.
This is to return quantiles either by value (for arithmetic types) or by const reference (for all other types)
auto begin |
Iterator pointing to the first entry in the view.
If the view is empty, the returned iterator must not be dereferenced or incremented.
auto end |
Iterator pointing to the past-the-end entry in the view.
The past-the-end entry is the hypothetical entry that would follow the last entry. It does not point to any entry, and must not be dereferenced or incremented.
size_t size |
double get_rank | ( | const T & | item, |
bool | inclusive = true |
||
) | const |
Returns an approximation to the normalized rank of the given item.
If the view is empty this throws std::runtime_error.
item | to be ranked |
inclusive | if true the weight of the given item is included into the rank. Otherwise the rank equals the sum of the weights of all items that are less than the given item according to the Comparator. |
auto get_quantile | ( | double | rank, |
bool | inclusive = true |
||
) | const |
Returns an item from the sketch that is the best approximation to an item from the original stream with the given normalized rank.
If the view is empty this throws std::runtime_error.
rank | of an item in the hypothetical sorted stream. |
inclusive | if true, the given rank is considered inclusive (includes weight of an item) |
auto get_CDF | ( | const T * | split_points, |
uint32_t | size, | ||
bool | inclusive = true |
||
) | const |
Returns an approximation to the Cumulative Distribution Function (CDF), which is the cumulative analog of the PMF, of the input stream given a set of split points (items).
If the view is empty this throws std::runtime_error.
split_points | an array of m unique, monotonically increasing items that divide the input domain into m+1 consecutive disjoint intervals. |
size | the number of split points in the array |
inclusive | if true the rank of an item includes its own weight, and therefore if the sketch contains items equal to a slit point, then in CDF such items are included into the interval to the left of split point. Otherwise they are included into the interval to the right of split point. |
auto get_PMF | ( | const T * | split_points, |
uint32_t | size, | ||
bool | inclusive = true |
||
) | const |
Returns an approximation to the Probability Mass Function (PMF) of the input stream given a set of split points (items).
If the view is empty this throws std::runtime_error.
split_points | an array of m unique, monotonically increasing items that divide the input domain into m+1 consecutive disjoint intervals (bins). |
size | the number of split points in the array |
inclusive | if true the rank of an item includes its own weight, and therefore if the sketch contains items equal to a slit point, then in PMF such items are included into the interval to the left of split point. Otherwise they are included into the interval to the right of split point. |