Stan Math Library  2.15.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 
11 
12 namespace stan {
13  namespace math {
14 
15  // Temporary neg_binomial_2_ccdf implementation that
16  // transforms the input parameters and calls neg_binomial_ccdf
17  template <typename T_n, typename T_location, typename T_precision>
19  neg_binomial_2_lccdf(const T_n& n,
20  const T_location& mu,
21  const T_precision& phi) {
22  if (!(stan::length(n)
23  && stan::length(mu)
24  && stan::length(phi)))
25  return 0.0;
26 
27  static const char* function("neg_binomial_2_lccdf");
28  check_positive_finite(function, "Location parameter", mu);
29  check_positive_finite(function, "Precision parameter", phi);
30  check_not_nan(function, "Random variable", n);
31  check_consistent_sizes(function,
32  "Random variable", n,
33  "Location parameter", mu,
34  "Precision Parameter", phi);
35 
38 
39  size_t size_beta = max_size(mu, phi);
40 
42  T_location, T_precision> beta_vec(size_beta);
43  for (size_t i = 0; i < size_beta; ++i)
44  beta_vec[i] = phi_vec[i] / mu_vec[i];
45 
46  return neg_binomial_ccdf_log(n, phi, beta_vec.data());
47  }
48 
49  }
50 }
51 #endif
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
size_t length(const std::vector< T > &x)
Definition: length.hpp:10
boost::math::tools::promote_args< typename scalar_type< T1 >::type, typename scalar_type< T2 >::type, typename scalar_type< T3 >::type, typename scalar_type< T4 >::type, typename scalar_type< T5 >::type, typename scalar_type< T6 >::type >::type type
Definition: return_type.hpp:27
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.
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.
VectorBuilderHelper< T1, used, contains_vector< T2, T3, T4, T5, T6, T7 >::value >::type data()
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–2016, Stan Development Team.