Skip to content

Commit 405322b

Browse files
committed
fix issue
1 parent 060a0df commit 405322b

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

stan/math/prim/prob/yule_simon_rng.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@ inline auto yule_simon_rng(const T_alpha &alpha, RNG &rng) {
3333
T_alpha_ref alpha_ref = alpha;
3434
check_positive_finite(function, "Shape parameter", alpha_ref);
3535

36-
using T_w = decltype(exponential_rng(alpha_ref, rng));
37-
T_w w = exponential_rng(alpha_ref, rng);
36+
auto w = exponential_rng(alpha_ref, rng);
37+
scalar_seq_view<decltype(w)> w_vec(w);
3838

39-
scalar_seq_view<T_w> w_vec(w);
4039
size_t size_w = stan::math::size(w);
41-
4240
VectorBuilder<true, int, T_alpha> output(size_w);
4341
for (size_t n = 0; n < size_w; ++n) {
44-
double p = stan::math::exp(-w_vec.val(n));
45-
double odds_ratio_p
42+
const double p = stan::math::exp(-w_vec[n]);
43+
const double odds_ratio_p
4644
= stan::math::exp(stan::math::log(p) - stan::math::log1m(p));
4745
output[n] = neg_binomial_rng(1.0, odds_ratio_p, rng) + 1;
4846
}

0 commit comments

Comments
 (0)