Skip to content

Commit

Permalink
One more edge case-test+fix
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmodrak committed Mar 12, 2020
1 parent c84a259 commit 6aed316
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stan/math/prim/fun/binomial_coefficient_log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ inline return_type_t<T_n, T_k> binomial_coefficient_log(const T_n n,
}

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

Expand Down
2 changes: 2 additions & 0 deletions test/unit/math/rev/fun/binomial_coefficient_log_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ std::vector<TestValue> testValuesEdge = {
{3, -1, stan::math::NEGATIVE_INFTY, -0.25, stan::math::INFTY},
{-1, -0.2, stan::math::INFTY, stan::math::NEGATIVE_INFTY,
-4.324031329886049836},
{-0.5, 0.5, stan::math::NEGATIVE_INFTY, stan::math::INFTY,
stan::math::NEGATIVE_INFTY},
{4.0, 5.0, stan::math::NEGATIVE_INFTY, stan::math::INFTY,
stan::math::NEGATIVE_INFTY},
{1, 0, 0, 0, 1},
Expand Down

0 comments on commit 6aed316

Please sign in to comment.