Skip to content

Commit 6aed316

Browse files
committed
One more edge case-test+fix
1 parent c84a259 commit 6aed316

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

stan/math/prim/fun/binomial_coefficient_log.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ inline return_type_t<T_n, T_k> binomial_coefficient_log(const T_n n,
8484
}
8585

8686
// Choosing the more stable of the symmetric branches
87-
if (n > 0 && k > value_of_rec(n) / 2.0 + 1e-8) {
87+
if (n > -1 && k > value_of_rec(n) / 2.0 + 1e-8) {
8888
return binomial_coefficient_log(n, n - k);
8989
}
9090

test/unit/math/rev/fun/binomial_coefficient_log_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ std::vector<TestValue> testValuesEdge = {
106106
{3, -1, stan::math::NEGATIVE_INFTY, -0.25, stan::math::INFTY},
107107
{-1, -0.2, stan::math::INFTY, stan::math::NEGATIVE_INFTY,
108108
-4.324031329886049836},
109+
{-0.5, 0.5, stan::math::NEGATIVE_INFTY, stan::math::INFTY,
110+
stan::math::NEGATIVE_INFTY},
109111
{4.0, 5.0, stan::math::NEGATIVE_INFTY, stan::math::INFTY,
110112
stan::math::NEGATIVE_INFTY},
111113
{1, 0, 0, 0, 1},

0 commit comments

Comments
 (0)