-
-
Notifications
You must be signed in to change notification settings - Fork 199
Closed
Description
Summary:
This was reported in stan-dev/stan#428.
When the 3rd argument, phi, is very large, the result ends up positive, which it should not.
Description:
There's a numerical error.
Reproducible Steps:
Put this in a test:
#include <stan/math.hpp>
#include <gtest/gtest.h>
TEST(NegBinomial2,) {
int N = 100;
double mu = 8;
double phi = 1e12;
for (int n = 0; n < 10; ++n) {
phi *= 10;
std::cout << "out = " << stan::math::neg_binomial_2_log<false>(N, mu, phi) << std::endl;
}
}Current Output:
out = -163.812
out = -163.5
out = -160
out = -128
out = 0
out = 8192
out = 0
out = 0
out = 0
out = 0
Expected Output:
All the output should be negative. I don't know why it returns the value of 8192.
Current Version:
v2.13.0