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

Calculate a single quantile from a fixed number of elements. More...

#include <SingleQuantile.hpp>

Public Member Functions

 SingleQuantileFixedNumber (const std::size_t num_total, const Output_ quantile)
 
std::size_t get_num_total () const
 
template<typename Input_ >
Output_ operator() (Input_ *const ptr) const
 
template<typename Input_ >
Output_ operator() (const std::size_t num_non_zero, Input_ *const ptr) const
 

Detailed Description

template<typename Output_ = double>
class quickstats::SingleQuantileFixedNumber< Output_ >

Calculate a single quantile from a fixed number of elements.

Template Parameters
Output_Floating-point type of the output quantile.

A SingleQuantileFixedNumber instance computes a type 7 quantile, consistent with the default in R's quantile function.

Constructor & Destructor Documentation

◆ SingleQuantileFixedNumber()

template<typename Output_ = double>
quickstats::SingleQuantileFixedNumber< Output_ >::SingleQuantileFixedNumber ( const std::size_t num_total,
const Output_ quantile )
inline
Parameters
num_totalTotal number of elements from which to compute a quantile. This should be positive.
quantileProbability of the quantile to compute, in \([0, 1]\).

Member Function Documentation

◆ get_num_total()

template<typename Output_ = double>
std::size_t quickstats::SingleQuantileFixedNumber< 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<typename Output_ = double>
template<typename Input_ >
Output_ quickstats::SingleQuantileFixedNumber< Output_ >::operator() ( Input_ *const ptr) const
inline

Compute the quantile of interest from a dense array.

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

Template Parameters
Input_Numeric type of the input values.
Parameters
[in]ptrPointer to the start of an array of length num_total. This should not contain any NaN values. On output, the elements may be reordered.
Returns
Quantile of the specified probability.

◆ operator()() [2/2]

template<typename Output_ = double>
template<typename Input_ >
Output_ quickstats::SingleQuantileFixedNumber< Output_ >::operator() ( const std::size_t num_non_zero,
Input_ *const ptr ) const
inline

Overload to compute the desired quantile from a sparse vector of length num_total. This vector should have num_non_zero structural non-zeros and num_total - num_non_zero structural 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.
Parameters
num_non_zeroNumber of structural non-zeros in the sparse vector. This should be no greater than num_total.
[in]ptrPointer to the start of an array of length num_non_zero, containing the values of the structural non-zeros of the sparse vector. It should not contain any NaN values. On output, the elements may be reordered.
Returns
Quantile of the specified probability.

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