Calculate a quantile from a variable number of elements.
More...
#include <SingleQuantile.hpp>
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.
◆ SingleQuantileVariableNumber()
template<typename Output_ >
- Parameters
-
| max_num_total | Maximum of the total number of elements. Unlike SingleQuantileFixedNumber, this may also be zero. |
| quantile | Probability of the quantile to compute, in \([0, 1]\). |
| options | Further options. |
◆ get_max_num_total()
template<typename Output_ >
- 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_ >
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_total | Total number of the elements from which to compute the quantile. This should be no greater than max_num_total. |
| [in] | ptr | Pointer 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_ >
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_total | Total number of elements from which to compute the quantile. This should be no greater than max_num_total. |
| num_non_zero | Number of elements that are structural non-zero elements. This should be no greater than num_total. |
| [in] | values | Pointer 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: