datasketches-cpp
Public Types | Public Member Functions | List of all members
quantiles_sorted_view< T, Comparator, Allocator > Class Template Reference

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...
 

Detailed Description

template<typename T, typename Comparator, typename Allocator>
class datasketches::quantiles_sorted_view< T, Comparator, Allocator >

Sorted view for quantiles sketches (REQ, KLL and Quantiles)

Member Typedef Documentation

◆ quantile_return_type

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)

Member Function Documentation

◆ begin()

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.

Returns
iterator pointing to the first entry

◆ end()

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.

Returns
iterator pointing to the past-the-end entry

◆ size()

size_t size
Returns
size of the view

◆ get_rank()

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.

Parameters
itemto be ranked
inclusiveif 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.
Returns
an approximate normalized rank of the given item (0 to 1 inclusive)

◆ get_quantile()

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.

Parameters
rankof an item in the hypothetical sorted stream.
inclusiveif true, the given rank is considered inclusive (includes weight of an item)
Returns
approximate quantile associated with the given normalized rank

◆ get_CDF()

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.

Parameters
split_pointsan array of m unique, monotonically increasing items that divide the input domain into m+1 consecutive disjoint intervals.
sizethe number of split points in the array
inclusiveif 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.
Returns
an array of m+1 doubles, which are a consecutive approximation to the CDF of the input stream given the split_points. The value at array position j of the returned CDF array is the sum of the returned values in positions 0 through j of the returned PMF array. This can be viewed as array of ranks of the given split points plus one more value that is always 1.

◆ get_PMF()

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.

Parameters
split_pointsan array of m unique, monotonically increasing items that divide the input domain into m+1 consecutive disjoint intervals (bins).
sizethe number of split points in the array
inclusiveif 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.
Returns
an array of m+1 doubles each of which is an approximation to the fraction of the input stream items (the mass) that fall into one of those intervals.

The documentation for this class was generated from the following files: