quickstats
Quickly compute simple statistics
Loading...
Searching...
No Matches
quickstats::MultipleQuantilesFixedNumber< Output_ > Class Template Reference

Calculate multiple quantiles from a fixed number of elements. More...

#include <MultipleQuantiles.hpp>

Public Member Functions

template<typename Quantiles_ >
 MultipleQuantilesFixedNumber (const std::size_t num_total, const Quantiles_ &quantiles)
 
std::size_t get_num_total () const
 
template<typename Input_ , class OutputFun_ >
void operator() (Input_ *const ptr, OutputFun_ output) const
 
template<typename Input_ , class OutputFun_ >
void operator() (const std::size_t num_non_zero, Input_ *const values, OutputFun_ output) const
 

Detailed Description

template<class Output_ = double>
class quickstats::MultipleQuantilesFixedNumber< Output_ >

Calculate multiple quantiles from a fixed number of elements.

Template Parameters
Output_Floating-point type of the output quantiles.

A MultipleQuantilesFixedNumber instance computes type 7 quantiles, consistent with the default in R's quantile function. It is equivalent to but more efficient than multiple calls to different SingleQuantileFixedNumber instances.

Constructor & Destructor Documentation

◆ MultipleQuantilesFixedNumber()

template<class Output_ = double>
template<typename Quantiles_ >
quickstats::MultipleQuantilesFixedNumber< Output_ >::MultipleQuantilesFixedNumber ( const std::size_t num_total,
const Quantiles_ & quantiles )
inline
Template Parameters
Quantiles_Container that has a size() method and supports access by [].
Parameters
num_totalTotal number of elements from which to compute a quantile. This should be positive.
quantilesContainer of sorted probabilities of the quantiles to compute. Each entry should be in \([0, 1]\).

Member Function Documentation

◆ get_num_total()

template<class Output_ = double>
std::size_t quickstats::MultipleQuantilesFixedNumber< Output_ >::get_num_total ( ) const
inline
Returns
Total number of elements, as specified in the num_total argument of the constructor.

◆ operator()() [1/2]

template<class Output_ = double>
template<typename Input_ , class OutputFun_ >
void quickstats::MultipleQuantilesFixedNumber< Output_ >::operator() ( Input_ *const ptr,
OutputFun_ output ) const
inline

Compute multiple quantiles from a dense array of length equal to num_total.

No consideration is given to special values like NaNs in the array. If these are to be skipped, consider using skip_values() before calling this method.

Template Parameters
Input_Numeric type of the input values.
OutputFun_Functor that accepts a std::size_t and an Output_.
Parameters
[in]ptrPointer to the start of an array of length num_total. On output, the elements may be reordered.
outputFunction that accepts a std::size_t, the index of the probability in quantiles; and an Output_, the computed value of the quantile. This will be called once for each quantile, in order of increasing index from 0 to quantiles.size() - 1.

◆ operator()() [2/2]

template<class Output_ = double>
template<typename Input_ , class OutputFun_ >
void quickstats::MultipleQuantilesFixedNumber< Output_ >::operator() ( const std::size_t num_non_zero,
Input_ *const values,
OutputFun_ output ) const
inline

Overload to compute the desired quantile from a sparse vector of length num_total. This vector is assumed to have num_non_zero structural non-zeros and num_total - num_non_zero zeros.

No consideration is given to special values like NaNs in the structural non-zeros. If these are to be skipped, consider using skip_values() before calling this method.

Template Parameters
Input_Numeric type of the input values.
OutputFun_Functor that accepts a std::size_t and an Output_.
Parameters
num_non_zeroNumber of structural non-zeros in the sparse vector. This should be no greater than num_total.
[in]valuesPointer to the start of an array of length num_non_zero, containing the values of the structural non-zeros of the sparse vector. On output, the elements may be reordered.
outputFunction that accepts a std::size_t, the index of the probability in quantiles; and an Output_, the computed value of the quantile. This will be called once for each quantile, in order of increasing index from 0 to quantiles.size() - 1.

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