1 #ifndef STAN_MATH_PRIM_SCAL_PROB_POISSON_CDF_HPP 2 #define STAN_MATH_PRIM_SCAL_PROB_POISSON_CDF_HPP 19 template <
typename T_n,
typename T_rate>
21 const T_rate& lambda) {
22 static const char*
function =
"poisson_cdf";
29 T_partials_return P(1.0);
49 return ops_partials.
build(0.0);
52 for (
size_t i = 0; i <
size; i++) {
58 const T_partials_return n_dbl =
value_of(n_vec[i]);
59 const T_partials_return lambda_dbl =
value_of(lambda_vec[i]);
60 const T_partials_return Pi =
gamma_q(n_dbl + 1, lambda_dbl);
65 ops_partials.
edge1_.partials_[i]
66 -=
exp(-lambda_dbl) *
pow(lambda_dbl, n_dbl) /
tgamma(n_dbl + 1) / Pi;
71 ops_partials.
edge1_.partials_[i] *= P;
73 return ops_partials.
build(P);
boost::math::tools::promote_args< double, typename partials_type< typename scalar_type< T >::type >::type, typename partials_return_type< T_pack... >::type >::type type
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Extends std::true_type when instantiated with zero or more template parameters, all of which extend t...
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
This template builds partial derivatives with respect to a set of operands.
size_t length(const std::vector< T > &x)
Returns the length of the provided std::vector.
bool size_zero(T &x)
Returns 1 if input is of length 0, returns 0 otherwise.
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
boost::math::tools::promote_args< double, typename scalar_type< T >::type, typename return_type< Types_pack... >::type >::type type
fvar< T > exp(const fvar< T > &x)
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
return_type< T_rate >::type poisson_cdf(const T_n &n, const T_rate &lambda)
size_t max_size(const T1 &x1, const T2 &x2)
T_return_type build(double value)
Build the node to be stored on the autodiff graph.
int max(const std::vector< int > &x)
Returns the maximum coefficient in the specified column vector.
int size(const std::vector< T > &x)
Return the size of the specified standard vector.
fvar< T > pow(const fvar< T > &x1, const fvar< T > &x2)
fvar< T > tgamma(const fvar< T > &x)
Return the result of applying the gamma function to the specified argument.
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.
fvar< T > gamma_q(const fvar< T > &x1, const fvar< T > &x2)
internal::ops_partials_edge< double, Op1 > edge1_