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

Calculate a quantile from a variable number of elements. More...

#include <SingleQuantile.hpp>

Public Member Functions

 SingleQuantileVariableNumber (const std::size_t max_num_total, const Output_ quantile, const SingleQuantileVariableNumberOptions< Output_ > &options)
 
std::size_t get_max_num_total () const
 
template<typename Input_ >
Output_ operator() (const std::size_t num_total, Input_ *ptr)
 
template<typename Input_ >
Output_ operator() (const std::size_t num_total, const std::size_t num_non_zero, Input_ *const values)
 

Detailed Description

template<typename Output_>
class quickstats::SingleQuantileVariableNumber< Output_ >

Calculate a quantile from a variable number of elements.

Template Parameters
Output_Floating-point type of the output quantile.

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

Constructor & Destructor Documentation

◆ SingleQuantileVariableNumber()

template<typename Output_ >
quickstats::SingleQuantileVariableNumber< Output_ >::SingleQuantileVariableNumber ( const std::size_t max_num_total,
const Output_ quantile,
const SingleQuantileVariableNumberOptions< Output_ > & options )
inline
Parameters
max_num_totalMaximum of the total number of elements. Unlike SingleQuantileFixedNumber, this may also be zero.
quantileProbability of the quantile to compute, in \([0, 1]\).
optionsFurther options.

Member Function Documentation

◆ get_max_num_total()

template<typename Output_ >
std::size_t quickstats::SingleQuantileVariableNumber< Output_ >::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_ >
template<typename Input_ >
Output_ quickstats::SingleQuantileVariableNumber< Output_ >::operator() ( const std::size_t num_total,
Input_ * ptr )
inline

Compute a single quantile 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.
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. This should not contain NaN values. On output, the elements may be reordered.
Returns
Quantile of the specified probability. If num_total == 0, SingleQuantileVariableNumberOptions::placeholder is returned instead.

◆ operator()() [2/2]

template<typename Output_ >
template<typename Input_ >
Output_ quickstats::SingleQuantileVariableNumber< Output_ >::operator() ( const std::size_t num_total,
const std::size_t num_non_zero,
Input_ *const values )
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.
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_total. 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.
Returns
Quantile of the specified probability. If num_total == 0, SingleQuantileVariableNumberOptions::placeholder is returned instead.

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