Skip to content

Commit fc7dc24

Browse files
authored
Revert "Revert "Add tests for var_value<Matrix> for univariate distributions""
1 parent ced3e01 commit fc7dc24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+770
-719
lines changed

make/tests

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ test/prob/generate_tests$(EXE) : test/prob/generate_tests.cpp
121121

122122

123123
## FIXME: think about how to do this generally using test_types
124-
# test_types := v fd fv ffd ffv
124+
# test_types := v fd fv ffd ffv vv
125125

126126
test_name = $(shell echo $(1) | sed 's,_[0-9]\{5\},_test.hpp,g')
127127

128128
.SECONDEXPANSION:
129-
test/prob/%_generated_v_test.cpp test/prob/%_generated_fd_test.cpp test/prob/%_generated_fv_test.cpp test/prob/%_generated_ffd_test.cpp test/prob/%_generated_ffv_test.cpp: test/prob/$$(call test_name,$$*) test/prob/generate_tests$(EXE)
129+
test/prob/%_generated_v_test.cpp test/prob/%_generated_fd_test.cpp test/prob/%_generated_fv_test.cpp test/prob/%_generated_ffd_test.cpp test/prob/%_generated_ffv_test.cpp test/prob/%_generated_vv_test.cpp: test/prob/$$(call test_name,$$*) test/prob/generate_tests$(EXE)
130130
$(WINE) test/prob/generate_tests$(EXE) $< $(N_TESTS)
131131

132-
LIST_OF_GENERATED_TESTS := $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_v_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_fd_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_fv_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_ffd_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_ffv_test.cpp,g')
132+
LIST_OF_GENERATED_TESTS := $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_v_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_fd_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_fv_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_ffd_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_ffv_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_vv_test.cpp,g')
133133

134134
.PHONY: generate-tests
135135
generate-tests: $(LIST_OF_GENERATED_TESTS)

stan/math/fwd/core/operator_division.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ inline fvar<T> operator/(const fvar<T>& x1, const fvar<T>& x2) {
3333
*/
3434
template <typename T, typename U, require_arithmetic_t<U>* = nullptr>
3535
inline fvar<T> operator/(const fvar<T>& x1, U x2) {
36-
return fvar<T>(x1.val_ / x2, x1.d_ / x2);
36+
return fvar<T>(x1.val_ / static_cast<double>(x2),
37+
x1.d_ / static_cast<double>(x2));
3738
}
3839

3940
/**
@@ -46,7 +47,8 @@ inline fvar<T> operator/(const fvar<T>& x1, U x2) {
4647
*/
4748
template <typename T, typename U, require_arithmetic_t<U>* = nullptr>
4849
inline fvar<T> operator/(U x1, const fvar<T>& x2) {
49-
return fvar<T>(x1 / x2.val_, -x1 * x2.d_ / (x2.val_ * x2.val_));
50+
return fvar<T>(static_cast<double>(x1) / x2.val_,
51+
-static_cast<double>(x1) * x2.d_ / (x2.val_ * x2.val_));
5052
}
5153

5254
template <typename T>

stan/math/prim/fun/scalar_seq_view.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ class scalar_seq_view<C, require_var_matrix_t<C>> {
6262
* @param i index
6363
* @return the element at the specified position in the container
6464
*/
65-
inline auto operator[](size_t i) const { return c_.val().coeffRef(i); }
65+
inline auto operator[](size_t i) const { return c_.coeff(i); }
6666
inline const auto* data() const noexcept { return c_.vi_; }
6767
inline auto* data() noexcept { return c_.vi_; }
6868

6969
inline auto size() const noexcept { return c_.size(); }
7070

7171
template <typename T = C, require_st_autodiff<T>* = nullptr>
7272
inline auto val(size_t i) const {
73-
return c_.val().coeffRef(i);
73+
return c_.val().coeff(i);
7474
}
7575

7676
template <typename T = C, require_st_autodiff<T>* = nullptr>

stan/math/prim/meta.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@
178178
#include <stan/math/prim/meta/compiler_attributes.hpp>
179179
#include <stan/math/prim/meta/contains_fvar.hpp>
180180
#include <stan/math/prim/meta/contains_std_vector.hpp>
181-
#include <stan/math/prim/meta/contains_vector.hpp>
182181
#include <stan/math/prim/meta/error_index.hpp>
183182
#include <stan/math/prim/meta/forward_as.hpp>
184183
#include <stan/math/prim/meta/holder.hpp>

stan/math/prim/meta/VectorBuilder.hpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#define STAN_MATH_PRIM_META_VECTORBUILDER_HPP
33

44
#include <stan/math/prim/meta/VectorBuilderHelper.hpp>
5-
#include <stan/math/prim/meta/contains_vector.hpp>
5+
#include <stan/math/prim/meta/disjunction.hpp>
6+
#include <stan/math/prim/meta/is_vector.hpp>
67

78
namespace stan {
89

@@ -25,7 +26,9 @@ namespace stan {
2526
template <bool used, typename T1, typename... Args>
2627
class VectorBuilder {
2728
private:
28-
using helper = VectorBuilderHelper<T1, used, contains_vector<Args...>::value>;
29+
using helper
30+
= VectorBuilderHelper<T1, used,
31+
math::disjunction<is_vector<Args>...>::value>;
2932

3033
public:
3134
using type = typename helper::type;

stan/math/prim/meta/contains_vector.hpp

-19
This file was deleted.

stan/math/prim/prob/bernoulli_cdf.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ return_type_t<T_prob> bernoulli_cdf(const T_n& n, const T_prob& theta) {
3434
check_consistent_sizes(function, "Random variable", n,
3535
"Probability parameter", theta);
3636
T_theta_ref theta_ref = theta;
37-
check_bounded(function, "Probability parameter", theta_ref, 0.0, 1.0);
37+
check_bounded(function, "Probability parameter", value_of(theta_ref), 0.0,
38+
1.0);
3839

3940
if (size_zero(n, theta)) {
4041
return 1.0;

stan/math/prim/prob/bernoulli_lccdf.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ return_type_t<T_prob> bernoulli_lccdf(const T_n& n, const T_prob& theta) {
3838
check_consistent_sizes(function, "Random variable", n,
3939
"Probability parameter", theta);
4040
T_theta_ref theta_ref = theta;
41-
check_bounded(function, "Probability parameter", theta_ref, 0.0, 1.0);
41+
check_bounded(function, "Probability parameter", value_of(theta_ref), 0.0,
42+
1.0);
4243

4344
if (size_zero(n, theta)) {
4445
return 0.0;

stan/math/prim/prob/bernoulli_lcdf.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ return_type_t<T_prob> bernoulli_lcdf(const T_n& n, const T_prob& theta) {
3838
check_consistent_sizes(function, "Random variable", n,
3939
"Probability parameter", theta);
4040
T_theta_ref theta_ref = theta;
41-
check_bounded(function, "Probability parameter", theta_ref, 0.0, 1.0);
41+
check_bounded(function, "Probability parameter", value_of(theta_ref), 0.0,
42+
1.0);
4243

4344
if (size_zero(n, theta)) {
4445
return 0.0;

stan/math/prim/prob/bernoulli_lpmf.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ return_type_t<T_prob> bernoulli_lpmf(const T_n& n, const T_prob& theta) {
4242
const T_n_ref n_ref = to_ref(n);
4343
const T_theta_ref theta_ref = to_ref(theta);
4444
check_bounded(function, "n", n_ref, 0, 1);
45-
check_bounded(function, "Probability parameter", theta_ref, 0.0, 1.0);
45+
check_bounded(function, "Probability parameter", value_of(theta_ref), 0.0,
46+
1.0);
4647

4748
if (size_zero(n, theta)) {
4849
return 0.0;
@@ -83,8 +84,8 @@ return_type_t<T_prob> bernoulli_lpmf(const T_n& n, const T_prob& theta) {
8384
logp += (N - sum) * log1m_theta;
8485

8586
if (!is_constant_all<T_prob>::value) {
86-
ops_partials.edge1_.partials_[0] += sum / theta_dbl;
87-
ops_partials.edge1_.partials_[0] += (N - sum) / (theta_dbl - 1);
87+
ops_partials.edge1_.partials_[0] += sum * inv(theta_dbl);
88+
ops_partials.edge1_.partials_[0] += (N - sum) * inv(theta_dbl - 1);
8889
}
8990
}
9091
} else {

stan/math/prim/prob/bernoulli_rng.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ inline typename VectorBuilder<true, int, T_theta>::type bernoulli_rng(
3232
using boost::variate_generator;
3333
static const char* function = "bernoulli_rng";
3434
ref_type_t<T_theta> theta_ref = theta;
35-
check_bounded(function, "Probability parameter", theta_ref, 0.0, 1.0);
35+
check_bounded(function, "Probability parameter", value_of(theta_ref), 0.0,
36+
1.0);
3637

3738
scalar_seq_view<T_theta> theta_vec(theta_ref);
3839
size_t N = stan::math::size(theta);

stan/math/prim/prob/beta_cdf.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ return_type_t<T_y, T_scale_succ, T_scale_fail> beta_cdf(
5252
T_beta_ref beta_ref = beta;
5353
check_positive_finite(function, "First shape parameter", alpha_ref);
5454
check_positive_finite(function, "Second shape parameter", beta_ref);
55-
check_bounded(function, "Random variable", y_ref, 0, 1);
55+
check_bounded(function, "Random variable", value_of(y_ref), 0, 1);
5656

5757
T_partials_return P(1.0);
5858
operands_and_partials<T_y_ref, T_alpha_ref, T_beta_ref> ops_partials(

stan/math/prim/prob/beta_lccdf.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ return_type_t<T_y, T_scale_succ, T_scale_fail> beta_lccdf(
6060
T_beta_ref beta_ref = beta_param;
6161
check_positive_finite(function, "First shape parameter", alpha_ref);
6262
check_positive_finite(function, "Second shape parameter", beta_ref);
63-
check_bounded(function, "Random variable", y_ref, 0, 1);
63+
check_bounded(function, "Random variable", value_of(y_ref), 0, 1);
6464

6565
T_partials_return ccdf_log(0.0);
6666
operands_and_partials<T_y_ref, T_alpha_ref, T_beta_ref> ops_partials(

stan/math/prim/prob/beta_lcdf.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ return_type_t<T_y, T_scale_succ, T_scale_fail> beta_lcdf(
6060
T_beta_ref beta_ref = beta_param;
6161
check_positive_finite(function, "First shape parameter", alpha_ref);
6262
check_positive_finite(function, "Second shape parameter", beta_ref);
63-
check_bounded(function, "Random variable", y_ref, 0, 1);
63+
check_bounded(function, "Random variable", value_of(y_ref), 0, 1);
6464

6565
T_partials_return cdf_log(0.0);
6666
operands_and_partials<T_y_ref, T_alpha_ref, T_beta_ref> ops_partials(

stan/math/prim/prob/beta_lpdf.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ return_type_t<T_y, T_scale_succ, T_scale_fail> beta_lpdf(
7979

8080
check_positive_finite(function, "First shape parameter", alpha_val);
8181
check_positive_finite(function, "Second shape parameter", beta_val);
82-
check_bounded(function, "Random variable", y_val, 0, 1);
82+
check_bounded(function, "Random variable", value_of(y_val), 0, 1);
8383
if (!include_summand<propto, T_y, T_scale_succ, T_scale_fail>::value) {
8484
return 0;
8585
}

stan/math/prim/prob/beta_proportion_lccdf.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ return_type_t<T_y, T_loc, T_prec> beta_proportion_lccdf(const T_y& y,
6161
T_y_ref y_ref = y;
6262
T_mu_ref mu_ref = mu;
6363
T_kappa_ref kappa_ref = kappa;
64-
check_positive(function, "Location parameter", mu_ref);
65-
check_less(function, "Location parameter", mu_ref, 1.0);
66-
check_positive_finite(function, "Precision parameter", kappa_ref);
67-
check_bounded(function, "Random variable", y_ref, 0.0, 1.0);
64+
check_positive(function, "Location parameter", value_of(mu_ref));
65+
check_less(function, "Location parameter", value_of(mu_ref), 1.0);
66+
check_positive_finite(function, "Precision parameter", value_of(kappa_ref));
67+
check_bounded(function, "Random variable", value_of(y_ref), 0.0, 1.0);
6868

6969
T_partials_return ccdf_log(0.0);
7070
operands_and_partials<T_y_ref, T_mu_ref, T_kappa_ref> ops_partials(

stan/math/prim/prob/beta_proportion_lcdf.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ return_type_t<T_y, T_loc, T_prec> beta_proportion_lcdf(const T_y& y,
6262
T_y_ref y_ref = y;
6363
T_mu_ref mu_ref = mu;
6464
T_kappa_ref kappa_ref = kappa;
65-
check_positive(function, "Location parameter", mu_ref);
66-
check_less(function, "Location parameter", mu_ref, 1.0);
67-
check_positive_finite(function, "Precision parameter", kappa_ref);
68-
check_bounded(function, "Random variable", y_ref, 0.0, 1.0);
65+
check_positive(function, "Location parameter", value_of(mu_ref));
66+
check_less(function, "Location parameter", value_of(mu_ref), 1.0);
67+
check_positive_finite(function, "Precision parameter", value_of(kappa_ref));
68+
check_bounded(function, "Random variable", value_of(y_ref), 0.0, 1.0);
6969

7070
T_partials_return cdf_log(0.0);
7171
operands_and_partials<T_y_ref, T_mu_ref, T_kappa_ref> ops_partials(

stan/math/prim/prob/beta_proportion_lpdf.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ return_type_t<T_y, T_loc, T_prec> beta_proportion_lpdf(const T_y& y,
7474

7575
const auto& y_arr = as_array_or_scalar(y_col);
7676
const auto& mu_arr = as_array_or_scalar(mu_col);
77-
const auto& kappa_arr
78-
= promote_scalar<T_partials_return_kappa>(as_array_or_scalar(kappa_col));
77+
const auto& kappa_arr = as_array_or_scalar(kappa_col);
7978

8079
ref_type_t<decltype(value_of(y_arr))> y_val = value_of(y_arr);
8180
ref_type_t<decltype(value_of(mu_arr))> mu_val = value_of(mu_arr);
@@ -84,7 +83,7 @@ return_type_t<T_y, T_loc, T_prec> beta_proportion_lpdf(const T_y& y,
8483
check_positive(function, "Location parameter", mu_val);
8584
check_less(function, "Location parameter", mu_val, 1.0);
8685
check_positive_finite(function, "Precision parameter", kappa_val);
87-
check_bounded(function, "Random variable", y_val, 0, 1);
86+
check_bounded(function, "Random variable", value_of(y_val), 0, 1);
8887

8988
if (!include_summand<propto, T_y, T_loc, T_prec>::value) {
9089
return 0;

stan/math/prim/prob/binomial_cdf.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ return_type_t<T_prob> binomial_cdf(const T_n& n, const T_N& N,
5151
T_theta_ref theta_ref = theta;
5252

5353
check_nonnegative(function, "Population size parameter", N_ref);
54-
check_bounded(function, "Probability parameter", theta_ref, 0.0, 1.0);
54+
check_bounded(function, "Probability parameter", value_of(theta_ref), 0.0,
55+
1.0);
5556

5657
if (size_zero(n, N, theta)) {
5758
return 1.0;

stan/math/prim/prob/binomial_lccdf.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ return_type_t<T_prob> binomial_lccdf(const T_n& n, const T_N& N,
5454
T_theta_ref theta_ref = theta;
5555

5656
check_nonnegative(function, "Population size parameter", N_ref);
57-
check_bounded(function, "Probability parameter", theta_ref, 0.0, 1.0);
57+
check_bounded(function, "Probability parameter", value_of(theta_ref), 0.0,
58+
1.0);
5859

5960
if (size_zero(n, N, theta)) {
6061
return 0;

stan/math/prim/prob/binomial_lcdf.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ return_type_t<T_prob> binomial_lcdf(const T_n& n, const T_N& N,
5454
T_theta_ref theta_ref = theta;
5555

5656
check_nonnegative(function, "Population size parameter", N_ref);
57-
check_bounded(function, "Probability parameter", theta_ref, 0.0, 1.0);
57+
check_bounded(function, "Probability parameter", value_of(theta_ref), 0.0,
58+
1.0);
5859

5960
if (size_zero(n, N, theta)) {
6061
return 0;

stan/math/prim/prob/binomial_logit_lpmf.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ return_type_t<T_prob> binomial_logit_lpmf(const T_n& n, const T_N& N,
6363
ref_type_t<decltype(value_of(N_arr))> N_val = value_of(N_arr);
6464
ref_type_t<decltype(value_of(alpha_arr))> alpha_val = value_of(alpha_arr);
6565

66-
check_bounded(function, "Successes variable", n_val, 0, N_val);
66+
check_bounded(function, "Successes variable", value_of(n_val), 0, N_val);
6767
check_nonnegative(function, "Population size parameter", N_val);
6868
check_finite(function, "Probability parameter", alpha_val);
6969

stan/math/prim/prob/binomial_lpmf.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ return_type_t<T_prob> binomial_lpmf(const T_n& n, const T_N& N,
5151
T_N_ref N_ref = N;
5252
T_theta_ref theta_ref = theta;
5353

54-
check_bounded(function, "Successes variable", n_ref, 0, N_ref);
54+
check_bounded(function, "Successes variable", value_of(n_ref), 0, N_ref);
5555
check_nonnegative(function, "Population size parameter", N_ref);
56-
check_bounded(function, "Probability parameter", theta_ref, 0.0, 1.0);
56+
check_bounded(function, "Probability parameter", value_of(theta_ref), 0.0,
57+
1.0);
5758

5859
if (size_zero(n, N, theta)) {
5960
return 0.0;

stan/math/prim/prob/binomial_rng.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ inline typename VectorBuilder<true, int, T_N, T_theta>::type binomial_rng(
4141
T_N_ref N_ref = N;
4242
T_theta_ref theta_ref = theta;
4343
check_nonnegative(function, "Population size parameter", N_ref);
44-
check_bounded(function, "Probability parameter", theta_ref, 0.0, 1.0);
44+
check_bounded(function, "Probability parameter", value_of(theta_ref), 0.0,
45+
1.0);
4546

4647
scalar_seq_view<T_N_ref> N_vec(N_ref);
4748
scalar_seq_view<T_theta_ref> theta_vec(theta_ref);

stan/math/prim/prob/categorical_lpmf.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ return_type_t<T_prob> categorical_lpmf(int n, const T_prob& theta) {
2020

2121
check_bounded(function, "Number of categories", n, 1, theta.size());
2222
ref_type_t<T_prob> theta_ref = theta;
23-
check_simplex(function, "Probabilities parameter", theta_ref);
23+
check_simplex(function, "Probabilities parameter", value_of(theta_ref));
2424

2525
if (include_summand<propto, T_prob>::value) {
2626
return log(theta_ref.coeff(n - 1));
@@ -36,7 +36,7 @@ return_type_t<T_prob> categorical_lpmf(const std::vector<int>& ns,
3636

3737
check_bounded(function, "element of outcome array", ns, 1, theta.size());
3838
ref_type_t<T_prob> theta_ref = theta;
39-
check_simplex(function, "Probabilities parameter", theta_ref);
39+
check_simplex(function, "Probabilities parameter", value_of(theta_ref));
4040

4141
if (!include_summand<propto, T_prob>::value) {
4242
return 0.0;

stan/math/prim/prob/hypergeometric_lpmf.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ template <bool propto, typename T_n, typename T_N, typename T_a, typename T_b>
1818
double hypergeometric_lpmf(const T_n& n, const T_N& N, const T_a& a,
1919
const T_b& b) {
2020
static const char* function = "hypergeometric_lpmf";
21-
check_bounded(function, "Successes variable", n, 0, a);
21+
check_bounded(function, "Successes variable", value_of(n), 0, a);
2222
check_consistent_sizes(function, "Successes variable", n, "Draws parameter",
2323
N, "Successes in population parameter", a,
2424
"Failures in population parameter", b);

stan/math/prim/prob/hypergeometric_rng.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ inline int hypergeometric_rng(int N, int a, int b, RNG& rng) {
1515
using boost::variate_generator;
1616
using boost::math::hypergeometric_distribution;
1717
static const char* function = "hypergeometric_rng";
18-
check_bounded(function, "Draws parameter", N, 0, a + b);
18+
check_bounded(function, "Draws parameter", value_of(N), 0, a + b);
1919
check_positive(function, "Draws parameter", N);
2020
check_positive(function, "Successes in population parameter", a);
2121
check_positive(function, "Failures in population parameter", b);

stan/math/prim/prob/poisson_binomial_lccdf.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ return_type_t<T_theta> poisson_binomial_lccdf(const T_y& y,
5151
for (size_t i = 0; i < max_sz; ++i) {
5252
check_bounded(function, "Successes variable", y_vec[i], 0,
5353
theta_vec[i].size());
54-
check_finite(function, "Probability parameters", theta_vec[i]);
55-
check_bounded(function, "Probability parameters", theta_vec[i], 0.0, 1.0);
54+
check_finite(function, "Probability parameters", theta_vec.val(i));
55+
check_bounded(function, "Probability parameters", theta_vec.val(i), 0.0,
56+
1.0);
5657
}
5758

5859
return sum(log1m_exp(log_sum_exp(poisson_binomial_log_probs(y, theta))));

stan/math/prim/prob/poisson_binomial_lcdf.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ return_type_t<T_theta> poisson_binomial_lcdf(const T_y& y,
5050
for (size_t i = 0; i < max_sz; ++i) {
5151
check_bounded(function, "Successes variable", y_vec[i], 0,
5252
theta_vec[i].size());
53-
check_finite(function, "Probability parameters", theta_vec[i]);
54-
check_bounded(function, "Probability parameters", theta_vec[i], 0.0, 1.0);
53+
check_finite(function, "Probability parameters", theta_vec.val(i));
54+
check_bounded(function, "Probability parameters", theta_vec.val(i), 0.0,
55+
1.0);
5556
}
5657

5758
return sum(log_sum_exp(poisson_binomial_log_probs(y, theta)));

stan/math/prim/prob/poisson_binomial_lpmf.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ return_type_t<T_theta> poisson_binomial_lpmf(const T_y& y,
4242
for (size_t i = 0; i < max_sz; ++i) {
4343
check_bounded(function, "Successes variable", y_vec[i], 0,
4444
theta_vec[i].size());
45-
check_finite(function, "Probability parameters", theta_vec[i]);
46-
check_bounded(function, "Probability parameters", theta_vec[i], 0.0, 1.0);
45+
check_finite(function, "Probability parameters", theta_vec.val(i));
46+
check_bounded(function, "Probability parameters", theta_vec.val(i), 0.0,
47+
1.0);
4748
}
4849

4950
return_type_t<T_theta> log_prob = 0.0;

stan/math/prim/prob/poisson_binomial_rng.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ inline int poisson_binomial_rng(
2727
const Eigen::Matrix<T_theta, Eigen::Dynamic, 1>& theta, RNG& rng) {
2828
static const char* function = "poisson_binomial_rng";
2929
check_finite(function, "Probability parameters", theta);
30-
check_bounded(function, "Probability parameters", theta, 0.0, 1.0);
30+
check_bounded(function, "Probability parameters", value_of(theta), 0.0, 1.0);
3131

3232
int y = 0;
3333
for (size_t i = 0; i < theta.size(); ++i) {

0 commit comments

Comments
 (0)