1 #ifndef __STAN__PROB__DISTRIBUTIONS__UNIVARIATE__CONTINUOUS__UNIFORM_HPP__
2 #define __STAN__PROB__DISTRIBUTIONS__UNIVARIATE__CONTINUOUS__UNIFORM_HPP__
37 template <
bool propto,
38 typename T_y,
typename T_low,
typename T_high,
41 uniform_log(
const T_y& y,
const T_low& alpha,
const T_high& beta,
43 static const char*
function =
"stan::prob::uniform_log(%1%)";
59 if(!
check_not_nan(
function, y,
"Random variable", &logp, Policy()))
61 if (!
check_finite(
function, alpha,
"Lower bound parameter", &logp, Policy()))
63 if (!
check_finite(
function, beta,
"Upper bound parameter", &logp, Policy()))
65 if (!
check_greater(
function, beta, alpha,
"Upper bound parameter",
70 "Random variable",
"Lower bound parameter",
"Upper bound parameter",
84 for (
size_t n = 0; n < N; n++) {
85 const double y_dbl =
value_of(y_vec[n]);
90 for (
size_t n = 0; n < N; n++) {
92 logp -=
log(beta_vec[n] - alpha_vec[n]);
98 template <
bool propto,
99 typename T_y,
typename T_low,
typename T_high>
102 uniform_log(
const T_y& y,
const T_low& alpha,
const T_high& beta) {
106 template <
typename T_y,
typename T_low,
typename T_high,
112 return uniform_log<false>(y,alpha,beta,Policy());
116 template <
typename T_y,
typename T_low,
typename T_high>
119 uniform_log(
const T_y& y,
const T_low& alpha,
const T_high& beta) {
double value_of(const agrad::var &v)
Return the value of the specified variable.
var log(const var &a)
Return the natural log of the specified variable (cmath).
double value_of(T x)
Return the value of the specified scalar argument converted to a double value.
bool check_not_nan(const char *function, const T_y &y, const char *name, T_result *result, const Policy &)
Checks if the variable y is nan.
bool check_greater(const char *function, const T_y &y, const T_low &low, const char *name, T_result *result, const Policy &)
bool check_consistent_sizes(const char *function, const T1 &x1, const T2 &x2, const char *name1, const char *name2, T_result *result, const Policy &)
bool check_finite(const char *function, const T_y &y, const char *name, T_result *result, const Policy &)
Checks if the variable y is finite.
boost::math::policies::policy default_policy
Default error-handling policy from Boost.
return_type< T_y, T_low, T_high >::type uniform_log(const T_y &y, const T_low &alpha, const T_high &beta, const Policy &)
The log of a uniform density for the given y, lower, and upper bound.
Probability, optimization and sampling library.
size_t length(const T &x)
size_t max_size(const T1 &x1, const T2 &x2)
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
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