The function gamma_q() goes into an infinite loop in the chain() method in the iterative algorithm when the second argument is too large.
The situation that tickled it was in a model Cody Ross submitted to stan-users, where there was an input:
avi->val_=8.01006; bvi->val_=2.47579e+215
The loop in question is:
double S = 0;
double s = 1;
...
int k = 0;
double delta = s / (avi_->val_ * avi_->val_);
while (std::fabs(delta) > 1e-6) {
S += delta;
++k;
s *= - bvi_->val_ / k;
delta = s / ((k + avi_->val_) * (k + avi_->val_));
}
We need to fix this loop so that it terminates with an exception and warning message rather than running forever.
Is there a better algorithm for this function? The loop at hand appears to not have very good convergence properties given the multiplication by vvi_->val_ at every step.
The function gamma_q() goes into an infinite loop in the chain() method in the iterative algorithm when the second argument is too large.
The situation that tickled it was in a model Cody Ross submitted to stan-users, where there was an input:
The loop in question is:
We need to fix this loop so that it terminates with an exception and warning message rather than running forever.
Is there a better algorithm for this function? The loop at hand appears to not have very good convergence properties given the multiplication by
vvi_->val_at every step.