Skip to content

Bug in qchisq? (PR#875)

1 message · Peter Dalgaard

#
Kenneth Cabrera <krcabrer@epm.net.co> writes:
Yup, that's a bug. We have in pnchisq.c

48          for (ux = 1.0; pnchisq(ux, n, lambda, lower_tail, log_p) <
p; ux *= 2);
49          for (lx = ux;  pnchisq(lx, n, lambda, lower_tail, log_p) >
p; lx *= 0.5);

but if we look at the opposite tail, we also need to reverse that
logic since pnchisq(x,...) is now decreasing in x. Otherwise the
algorithm will get stuck in one of the for loops.

(Mailed to r-bugs)