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

◆ quantile() [1/2]

template<typename T , require_vector_t< T > * = nullptr, require_vector_vt< std::is_arithmetic, T > * = nullptr>
double stan::math::quantile ( const T &  samples_vec,
const double  p 
)
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>
Parameters
samples_vecNumeric vector whose sample quantiles are wanted
pProbability with value between 0 and 1.
Returns
Sample quantile.
Exceptions
std::invalid_argumentIf any element of samples_vec is NaN, or size 0.
std::domain_errorIf p<0 or p>1.

Definition at line 32 of file quantile.hpp.