Stan Math Library  2.20.0
reverse mode automatic differentiation
ordered_probit_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_PROB_ORDERED_PROBIT_RNG_HPP
2 #define STAN_MATH_PRIM_MAT_PROB_ORDERED_PROBIT_RNG_HPP
3 
10 
11 namespace stan {
12 namespace math {
13 
14 template <class RNG>
15 inline int ordered_probit_rng(double eta, const Eigen::VectorXd& c, RNG& rng) {
16  static const char* function = "ordered_probit";
17 
18  check_finite(function, "Location parameter", eta);
19  check_greater(function, "Size of cut points parameter", c.size(), 0);
20  check_ordered(function, "Cut points vector", c);
21  check_finite(function, "Cut-points", c);
22 
23  Eigen::VectorXd cut(c.rows() + 1);
24  cut(0) = 1 - Phi(eta - c(0));
25  for (int j = 1; j < c.rows(); j++)
26  cut(j) = Phi(eta - c(j - 1)) - Phi(eta - c(j));
27  cut(c.rows()) = Phi(eta - c(c.rows() - 1));
28 
29  return categorical_rng(cut, rng);
30 }
31 
32 } // namespace math
33 } // namespace stan
34 #endif
void check_finite(const char *function, const char *name, const T_y &y)
Check if y is finite.
void check_ordered(const char *function, const char *name, const std::vector< T_y > &y)
Check if the specified vector is sorted into strictly increasing order.
int categorical_rng(const Eigen::Matrix< double, Eigen::Dynamic, 1 > &theta, RNG &rng)
int ordered_probit_rng(double eta, const Eigen::VectorXd &c, RNG &rng)
fvar< T > Phi(const fvar< T > &x)
Definition: Phi.hpp:13
void check_greater(const char *function, const char *name, const T_y &y, const T_low &low)
Check if y is strictly greater than low.

     [ Stan Home Page ] © 2011–2018, Stan Development Team.