Bug 15521 - qcauchy accuracy for p near 1
qcauchy accuracy for p near 1
Status: RESOLVED FIXED
Product: R
Classification: Unclassified
Component: Accuracy
R 3.0.1
Other All
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-31 13:38 UTC by M Welinder
Modified: 2013-11-01 16:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description M Welinder 2013-10-31 13:38:10 UTC
options(digits=16)
qcauchy(1-2^-20,-1.5,0.5)
[1] 166884.553606629

A more correct value is

    166884.5536070279008948029050725428741902111014619503913976725...

WolframAlpha: -1.5-0.5/tan(Pi*(1-2^-20))


The fix is simple: flip tails for p>0.5 in the non-log case.

	if (p > 0.5) {
		p = 1 - p;
		lower_tail = !lower_tail;
	}

Note: the log-case already contains a tail flip, but the cut-off is 1/e.
It's probably not important, but 1/2 seems like a less strange choice.
Comment 1 Martin Maechler 2013-11-01 16:10:44 UTC
fixed for R-devel and R-patched (3.0.2).
[[not touching the log_p branch]]