Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ quantile() [2/2]

template<typename T , typename Tp , require_all_vector_t< T, Tp > * = nullptr, require_vector_vt< std::is_arithmetic, T > * = nullptr, require_std_vector_vt< std::is_arithmetic, Tp > * = nullptr>
std::vector< double > stan::math::quantile ( const T &  samples_vec,
const Tp &  ps 
)
inline

Return sample quantiles corresponding to the given probabilities.

The smallest observation corresponds to a probability of 0 and the largest to a probability of 1.

Implements algorithm 7 from Hyndman, R. J. and Fan, Y., Sample quantiles in Statistical Packages (R's default quantile function)

Template Parameters
TAn Eigen type with either fixed rows or columns at compile time, or std::vector<double>
TpType of probabilities vector
Parameters
samples_vecNumeric vector whose sample quantiles are wanted
psVector of probability with value between 0 and 1.
Returns
Sample quantiles, one for each p in ps.
Exceptions
std::invalid_argumentIf any of the values are NaN or size 0.
std::domain_errorIf p<0 or p>1 for any p in ps.

Definition at line 81 of file quantile.hpp.