All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
neg_binomial_2_ccdf_log.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_SCAL_PROB_NEG_BINOMIAL_2_CCDF_LOG_HPP
#define STAN_MATH_PRIM_SCAL_PROB_NEG_BINOMIAL_2_CCDF_LOG_HPP
#include <boost/math/special_functions/digamma.hpp>
#include <boost/random/negative_binomial_distribution.hpp>
#include <boost/random/variate_generator.hpp>
#include <stan/math/prim/scal/meta/OperandsAndPartials.hpp>
#include <stan/math/prim/scal/err/check_consistent_sizes.hpp>
#include <stan/math/prim/scal/err/check_not_nan.hpp>
#include <stan/math/prim/scal/err/check_positive_finite.hpp>
#include <stan/math/prim/scal/err/check_nonnegative.hpp>
#include <stan/math/prim/scal/err/check_less.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/binomial_coefficient_log.hpp>
#include <stan/math/prim/scal/fun/multiply_log.hpp>
#include <stan/math/prim/scal/fun/digamma.hpp>
#include <stan/math/prim/scal/fun/lgamma.hpp>
#include <stan/math/prim/scal/fun/value_of.hpp>
#include <stan/math/prim/scal/meta/include_summand.hpp>
#include <stan/math/prim/scal/prob/neg_binomial_ccdf_log.hpp>
#include <stan/math/prim/scal/fun/grad_reg_inc_beta.hpp>
#include <stan/math/prim/scal/meta/VectorBuilder.hpp>
#include <vector>
namespace stan {
namespace math {
// Temporary neg_binomial_2_ccdf implementation that
// transforms the input parameters and calls neg_binomial_ccdf
template <typename T_n, typename T_location, typename T_precision>
typename return_type<T_location, T_precision>::type
neg_binomial_2_ccdf_log(const T_n& n,
const T_location& mu,
const T_precision& phi) {
if ( !( stan::length(n) && stan::length(mu) && stan::length(phi) ) )
return 0.0;
using stan::math::check_nonnegative;
using stan::math::check_positive_finite;
using stan::math::check_not_nan;
using stan::math::check_consistent_sizes;
using stan::math::check_less;
static const char* function("stan::math::neg_binomial_2_cdf");
check_positive_finite(function, "Location parameter", mu);
check_positive_finite(function, "Precision parameter", phi);
check_not_nan(function, "Random variable", n);
check_consistent_sizes(function,
"Random variable", n,
"Location parameter", mu,
"Precision Parameter", phi);
VectorView<const T_n> n_vec(n);
VectorView<const T_location> mu_vec(mu);
VectorView<const T_precision> phi_vec(phi);
size_t size_beta = max_size(mu, phi);
std::vector<typename return_type<T_location, T_precision>::type>
beta_vec(size_beta);
for (size_t i = 0; i < size_beta; ++i)
beta_vec[i] = phi_vec[i] / mu_vec[i];
// Cast a vector of size 1 down to a
// scalar to avoid dimension mismatch
if (size_beta == 1)
return neg_binomial_ccdf_log(n, phi, beta_vec[0]);
else
return neg_binomial_ccdf_log(n, phi, beta_vec);
}
}
}
#endif
check_not_nan.hpp
stan::math::check_less
bool check_less(const char *function, const char *name, const T_y &y, const T_high &high)
Return true if y is strictly less than high.
Definition: check_less.hpp:81
lgamma.hpp
stan::math::check_not_nan
bool check_not_nan(const char *function, const char *name, const T_y &y)
Return true if y is not NaN.
Definition: check_not_nan.hpp:63
check_positive_finite.hpp
stan::math::neg_binomial_2_ccdf_log
return_type< T_location, T_precision >::type neg_binomial_2_ccdf_log(const T_n &n, const T_location &mu, const T_precision &phi)
Definition: neg_binomial_2_ccdf_log.hpp:33
digamma.hpp
stan::length
size_t length(const std::vector< T > &x)
Definition: length.hpp:10
neg_binomial_ccdf_log.hpp
binomial_coefficient_log.hpp
include_summand.hpp
multiply_log.hpp
check_nonnegative.hpp
stan::math::neg_binomial_ccdf_log
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)
Definition: neg_binomial_ccdf_log.hpp:32
OperandsAndPartials.hpp
stan::max_size
size_t max_size(const T1 &x1, const T2 &x2)
Definition: max_size.hpp:9
VectorBuilder.hpp
grad_reg_inc_beta.hpp
constants.hpp
stan::math::check_consistent_sizes
bool check_consistent_sizes(const char *function, const char *name1, const T1 &x1, const char *name2, const T2 &x2)
Return true if the dimension of x1 is consistent with x2.
Definition: check_consistent_sizes.hpp:31
stan::math::check_nonnegative
bool check_nonnegative(const char *function, const char *name, const T_y &y)
Return true if y is non-negative.
Definition: check_nonnegative.hpp:66
value_of.hpp
stan::VectorView
VectorView is a template metaprogram that takes its argument and allows it to be used like a vector...
Definition: VectorView.hpp:41
check_less.hpp
check_consistent_sizes.hpp
stan::math::check_positive_finite
bool check_positive_finite(const char *function, const char *name, const T_y &y)
Return true if y is positive and finite.
Definition: check_positive_finite.hpp:28

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