Automatic Differentiation
 
Loading...
Searching...
No Matches
neg_binomial_2_lccdf.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_PROB_NEG_BINOMIAL_2_LCCDF_HPP
2#define STAN_MATH_PRIM_PROB_NEG_BINOMIAL_2_LCCDF_HPP
3
10
11namespace stan {
12namespace math {
13
14// Temporary neg_binomial_2_ccdf implementation that
15// transforms the input parameters and calls neg_binomial_ccdf
16template <typename T_n, typename T_location, typename T_precision>
18 const T_n& n, const T_location& mu, const T_precision& phi) {
19 using T_mu_ref = ref_type_t<T_location>;
20 using T_phi_ref = ref_type_t<T_precision>;
21 static constexpr const char* function = "neg_binomial_2_lccdf";
22 check_consistent_sizes(function, "Random variable", n, "Location parameter",
23 mu, "Precision Parameter", phi);
24 T_mu_ref mu_ref = mu;
25 T_phi_ref phi_ref = phi;
26 check_positive_finite(function, "Location parameter", mu_ref);
27 check_positive_finite(function, "Precision parameter", phi_ref);
28 check_not_nan(function, "Random variable", n);
29
30 if (size_zero(n, mu, phi)) {
31 return 0;
32 }
33
34 scalar_seq_view<T_mu_ref> mu_vec(mu_ref);
35 scalar_seq_view<T_phi_ref> phi_vec(phi_ref);
36 size_t size_beta = max_size(mu, phi);
37
39 T_precision>
40 beta_vec(size_beta);
41 for (size_t i = 0; i < size_beta; ++i) {
42 beta_vec[i] = phi_vec[i] / mu_vec[i];
43 }
44
45 return neg_binomial_lccdf(n, phi_ref, beta_vec.data());
46}
47
48} // namespace math
49} // namespace stan
50#endif
VectorBuilder allocates type T1 values to be used as intermediate values.
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
bool size_zero(const T &x)
Returns 1 if input is of length 0, returns 0 otherwise.
Definition size_zero.hpp:19
void check_consistent_sizes(const char *)
Trivial no input case, this function is a no-op.
return_type_t< T_shape, T_inv_scale > neg_binomial_lccdf(const T_n &n, const T_shape &alpha, const T_inv_scale &beta_param)
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
int64_t max_size(const T1 &x1, const Ts &... xs)
Calculate the size of the largest input.
Definition max_size.hpp:20
return_type_t< T_location, T_precision > neg_binomial_2_lccdf(const T_n &n, const T_location &mu, const T_precision &phi)
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.
typename ref_type_if< true, T >::type ref_type_t
Definition ref_type.hpp:55
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...