1#ifndef STAN_MATH_PRIM_PROB_VON_MISES_CDF_HPP
2#define STAN_MATH_PRIM_PROB_VON_MISES_CDF_HPP
22template <
typename T_x,
typename T_k>
36 for (n = 1; n < p; n++) {
37 auto sn_tmp = sn * c - cn * s;
40 R = 1 / (2.0 * (p - n) / k + R);
41 V = R * (sn / (p - n) + V);
51template <
typename T_x,
typename T_k>
57 const auto z = b *
sin(x / 2);
59 const double sigma = 1;
70template <
typename T_x,
typename T_k>
117template <
typename T_x,
typename T_mu,
typename T_k>
127 static char const* function =
"von_mises_cdf";
129 mu,
"Scale parameter", k);
132 T_mu_ref mu_ref = mu;
150 for (
size_t n = 0; n < N; ++n) {
152 auto mu_n = mu_vec[n];
157 }
else if (x_n ==
pi) {
161 T_return x2 = x_n - mu_n;
166 const auto x_modded = x2 - x_floor *
TWO_PI;
170 T_return mu2 = mu_n +
pi;
172 const auto mu_modded = mu2 - mu_floor *
TWO_PI;
173 mu2 = mu_modded -
pi;
176 T_return cut, bound_val;
179 bound_val = -
pi - mu2;
183 bound_val =
pi - mu2;
186 T_return f_bound_val = von_mises_cdf_centered(bound_val, k_n);
189 cdf_n = von_mises_cdf_centered(x2, k_n) - f_bound_val;
191 cdf_n = von_mises_cdf_centered(x2, k_n) + 1 - f_bound_val;
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
return_type_t< T_y_cl, T_loc_cl, T_scale_cl > normal_cdf(const T_y_cl &y, const T_loc_cl &mu, const T_scale_cl &sigma)
Returns the normal cumulative distribution function for the given location, and scale.
return_type_t< T_x, T_mu, T_k > von_mises_cdf(const T_x &x, const T_mu &mu, const T_k &k)
Calculates the cumulative distribution function of the von Mises distribution:
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
return_type_t< T_x, T_k > von_mises_cdf_normalapprox(const T_x &x, const T_k &k)
conv_mises_cdf_normapprox(x, k) is used to approximate the von Mises cdf for k > 50.
return_type_t< T_x, T_k > von_mises_cdf_series(const T_x &x, const T_k &k)
This implementation of the von Mises cdf is a copy of scipy's.
return_type_t< T_x, T_k > von_mises_cdf_centered(const T_x &x, const T_k &k)
This function calculates the cdf of the von Mises distribution in the case where the distribution has...
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
fvar< T > sin(const fvar< T > &x)
bool size_zero(const T &x)
Returns 1 if input is of length 0, returns 0 otherwise.
void check_bounded(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
Check if the value is between the low and high values, inclusively.
T value_of(const fvar< T > &v)
Return the value of the specified variable.
fvar< T > modified_bessel_first_kind(int v, const fvar< T > &z)
void check_consistent_sizes(const char *)
Trivial no input case, this function is a no-op.
fvar< T > sqrt(const fvar< T > &x)
void check_finite(const char *function, const char *name, const T_y &y)
Return true if all values in y are finite.
fvar< T > floor(const fvar< T > &x)
fvar< T > cos(const fvar< T > &x)
static constexpr double TWO_PI
Twice the value of , .
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
static constexpr double pi()
Return the value of pi.
int64_t max_size(const T1 &x1, const Ts &... xs)
Calculate the size of the largest input.
fvar< T > exp(const fvar< T > &x)
typename ref_type_if< true, T >::type ref_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...