Skip to content

Commit 3bd3431

Browse files
committed
fix test
1 parent a936073 commit 3bd3431

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

stan/math/prim/prob/yule_simon_rng.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define STAN_MATH_PRIM_PROB_YULE_SIMON_RNG_HPP
33

44
#include <stan/math/prim/meta.hpp>
5+
#include <stan/math/prim/fun/log1m.hpp>
56
#include <stan/math/prim/prob/exponential_rng.hpp>
67
#include <stan/math/prim/prob/neg_binomial_rng.hpp>
78

@@ -38,8 +39,9 @@ inline auto yule_simon_rng(const T_alpha &alpha, RNG &rng) {
3839

3940
VectorBuilder<true, int, T_alpha> output(size_w);
4041
for (size_t n = 0; n < size_w; ++n) {
41-
double p = exp(-w_vec.val(n));
42-
double odds_ratio_p = exp(log(p) - log1m(p));
42+
double p = stan::math::exp(-w_vec.val(n));
43+
double odds_ratio_p
44+
= stan::math::exp(stan::math::log(p) - stan::math::log1m(p));
4345
output[n] = neg_binomial_rng(1.0, odds_ratio_p, rng) + 1;
4446
}
4547

test/unit/math/prim/prob/yule_simon_test.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,17 @@ TEST(ProbDistributionsYuleSimon, distributionCheck) {
3838
TEST(ProbDistributionsYuleSimon, error_check) {
3939
boost::random::mt19937 rng;
4040

41-
// Valid parameters should not throw
4241
EXPECT_NO_THROW(stan::math::yule_simon_rng(1.0, rng));
4342
EXPECT_NO_THROW(stan::math::yule_simon_rng(2.0, rng));
4443
EXPECT_NO_THROW(stan::math::yule_simon_rng(10.0, rng));
4544

46-
// Invalid parameters should throw domain_error
4745
EXPECT_THROW(stan::math::yule_simon_rng(-0.5, rng), std::domain_error);
4846
EXPECT_THROW(stan::math::yule_simon_rng(0.0, rng), std::domain_error);
4947
EXPECT_THROW(stan::math::yule_simon_rng(-10.0, rng), std::domain_error);
5048

51-
// Infinity should throw
5249
EXPECT_THROW(stan::math::yule_simon_rng(stan::math::positive_infinity(), rng),
5350
std::domain_error);
5451

55-
// NaN should throw
5652
EXPECT_THROW(stan::math::yule_simon_rng(stan::math::not_a_number(), rng),
5753
std::domain_error);
5854
}

0 commit comments

Comments
 (0)