Stan Math Library  2.20.0
reverse mode automatic differentiation
neg_binomial_2_lccdf.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_NEG_BINOMIAL_2_LCCDF_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_NEG_BINOMIAL_2_LCCDF_HPP
3 
10 
11 namespace stan {
12 namespace math {
13 
14 // Temporary neg_binomial_2_ccdf implementation that
15 // transforms the input parameters and calls neg_binomial_ccdf
16 template <typename T_n, typename T_location, typename T_precision>
18  const T_n& n, const T_location& mu, const T_precision& phi) {
19  if (size_zero(n, mu, phi))
20  return 0.0;
21 
22  static const char* function = "neg_binomial_2_lccdf";
23  check_positive_finite(function, "Location parameter", mu);
24  check_positive_finite(function, "Precision parameter", phi);
25  check_not_nan(function, "Random variable", n);
26  check_consistent_sizes(function, "Random variable", n, "Location parameter",
27  mu, "Precision Parameter", phi);
28 
29  scalar_seq_view<T_location> mu_vec(mu);
30  scalar_seq_view<T_precision> phi_vec(phi);
31 
32  size_t size_beta = max_size(mu, phi);
33 
35  T_location, T_precision>
36  beta_vec(size_beta);
37  for (size_t i = 0; i < size_beta; ++i)
38  beta_vec[i] = phi_vec[i] / mu_vec[i];
39 
40  return neg_binomial_ccdf_log(n, phi, beta_vec.data());
41 }
42 
43 } // namespace math
44 } // namespace stan
45 #endif
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
bool size_zero(T &x)
Returns 1 if input is of length 0, returns 0 otherwise.
Definition: size_zero.hpp:18
return_type< T_location, T_precision >::type neg_binomial_2_lccdf(const T_n &n, const T_location &mu, const T_precision &phi)
return_type< T_shape, T_inv_scale >::type neg_binomial_ccdf_log(const T_n &n, const T_shape &alpha, const T_inv_scale &beta)
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.
boost::math::tools::promote_args< double, typename scalar_type< T >::type, typename return_type< Types_pack... >::type >::type type
Definition: return_type.hpp:36
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
size_t max_size(const T1 &x1, const T2 &x2)
Definition: max_size.hpp:9
VectorBuilder allocates type T1 values to be used as intermediate values.
void check_consistent_sizes(const char *function, const char *name1, const T1 &x1, const char *name2, const T2 &x2)
Check if the dimension of x1 is consistent with x2.

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