1 #ifndef STAN_MATH_PRIM_SCAL_PROB_VON_MISES_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_VON_MISES_RNG_HPP
36 using boost::variate_generator;
42 static const char*
function(
"stan::math::von_mises_rng");
47 double r = 1 +
pow((1 + 4 * kappa * kappa), 0.5);
48 double rho = 0.5 * (r -
pow(2 * r, 0.5)) / kappa;
49 double s = 0.5 * (1 + rho * rho) / rho;
55 W = (1 + s * Z) / (s + Z);
56 double Y = kappa * (s - W);
58 done = Y * (2 - Y) - U2 > 0;
61 done =
log(Y / U2) + 1 - Y >= 0;
65 double sign = ((U3 >= 0) - (U3 <= 0));
fvar< T > cos(const fvar< T > &x)
fvar< T > log(const fvar< T > &x)
fvar< T > fmod(const fvar< T > &x1, const fvar< T > &x2)
double von_mises_rng(const double mu, const double kappa, RNG &rng)
double uniform_rng(const double alpha, const double beta, RNG &rng)
fvar< T > acos(const fvar< T > &x)
bool check_finite(const char *function, const char *name, const T_y &y)
Return true if y is finite.
double pi()
Return the value of pi.
fvar< T > pow(const fvar< T > &x1, const fvar< T > &x2)
bool check_positive_finite(const char *function, const char *name, const T_y &y)
Return true if y is positive and finite.