Calculate multiple quantiles from a fixed number of elements.
More...
#include <MultipleQuantiles.hpp>
|
| 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 |
| |
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.
◆ MultipleQuantilesFixedNumber()
template<class Output_ = double>
template<typename Quantiles_ >
- Template Parameters
-
| Quantiles_ | Container that has a size() method and supports access by []. |
- Parameters
-
| num_total | Total number of elements from which to compute a quantile. This should be positive. |
| quantiles | Container of sorted probabilities of the quantiles to compute. Each entry should be in \([0, 1]\). |
◆ get_num_total()
template<class Output_ = double>
- 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_ >
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] | ptr | Pointer to the start of an array of length num_total. On output, the elements may be reordered. |
| output | Function 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_ >
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_zero | Number of structural non-zeros in the sparse vector. This should be no greater than num_total. |
| [in] | values | Pointer 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. |
| output | Function 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: