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

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

#include <MultipleQuantiles.hpp>

Public Member Functions

 MultipleQuantilesVariableNumber (const std::size_t max_num_total, QuantilesPointer_ quantiles_ptr, const MultipleQuantilesVariableNumberOptions< Output_ > &options)
 
std::size_t get_max_num_total () const
 
template<typename Input_ , class OutputFun_ >
void operator() (const std::size_t num_total, Input_ *const ptr, OutputFun_ output)
 
template<typename Input_ , class OutputFun_ >
void operator() (const std::size_t num_total, const std::size_t num_non_zero, Input_ *const values, OutputFun_ output)
 

Detailed Description

template<typename Output_, class QuantilesPointer_>
class quickstats::MultipleQuantilesVariableNumber< Output_, QuantilesPointer_ >

Calculate multiple quantiles from a variable number of elements.

Template Parameters
Output_Floating-point type of the output quantile.
QuantilesPointer_Pointer to a container that has a size() method and supports access by []. This may or may not be a smart pointer.

This uses the same logic as the MultipleQuantilesFixedNumber class but supports any number of elements, from zero up to a specified maximum.

Constructor & Destructor Documentation

◆ MultipleQuantilesVariableNumber()

template<typename Output_ , class QuantilesPointer_ >
quickstats::MultipleQuantilesVariableNumber< Output_, QuantilesPointer_ >::MultipleQuantilesVariableNumber ( const std::size_t max_num_total,
QuantilesPointer_ quantiles_ptr,
const MultipleQuantilesVariableNumberOptions< Output_ > & options )
inline
Parameters
max_num_totalMaximum of the total number of elements. Unlike MultipleQuantilesFixedNumber, this may also be zero.
quantiles_ptrPointer to a container of sorted quantile probabilities. Each probability should be in \([0, 1]\).
optionsFurther options.

Member Function Documentation

◆ get_max_num_total()

template<typename Output_ , class QuantilesPointer_ >
std::size_t quickstats::MultipleQuantilesVariableNumber< Output_, QuantilesPointer_ >::get_max_num_total ( ) const
inline
Returns
Maximum number of elements, as specified in the max_num_total argument of the constructor.

◆ operator()() [1/2]

template<typename Output_ , class QuantilesPointer_ >
template<typename Input_ , class OutputFun_ >
void quickstats::MultipleQuantilesVariableNumber< Output_, QuantilesPointer_ >::operator() ( const std::size_t num_total,
Input_ *const ptr,
OutputFun_ output )
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.

This method is not thread-safe.

Template Parameters
Input_Numeric type of the input values.
OutputFun_Functor that accepts a std::size_t and an Output_.
Parameters
num_totalTotal number of the elements from which to compute the quantile. This should be no greater than max_num_total.
[in]ptrPointer to 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. The value of the quantile will be set to MultipleQuantilesVariableNumberOptions::placeholder if num_total == 0.

◆ operator()() [2/2]

template<typename Output_ , class QuantilesPointer_ >
template<typename Input_ , class OutputFun_ >
void quickstats::MultipleQuantilesVariableNumber< Output_, QuantilesPointer_ >::operator() ( const std::size_t num_total,
const std::size_t num_non_zero,
Input_ *const values,
OutputFun_ output )
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 values of the structural non-zeros. If these are to be skipped, consider using skip_values() before calling this method.

This method is not thread-safe.

Template Parameters
Input_Numeric type of the input values.
OutputFun_Functor that accepts a std::size_t and an Output_.
Parameters
num_totalTotal number of elements from which to compute the quantile. This should be no greater than max_num_total.
num_non_zeroNumber of elements that are structural non-zero elements. This should be no greater than num_total.
[in]valuesPointer to the start of an array of length num_non_zero. This is expected to contain the values of the structural non-zero elements of the sparse vector. It should not contain any NaN values. 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 value of the quantile will be set to MultipleQuantilesVariableNumberOptions::placeholder if num_total == 0.

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