The GitHub Actions job "Java CI" on 
commons-statistics.git/fix/cauchy-quantile-tails has failed.
Run started by GitHub user simpleqt (triggered by aherbert).

Head commit for run:
e52760fae1e79a909aeccbf4047cd48fdbc16a70 / simpleqt <[email protected]>
Fix the Cauchy distribution quantile function in the tails

CauchyDistribution.inverseCumulativeProbability(p) computes
location + scale * tan(pi * (p - 0.5)). For a probability close to 0 or 1 the
subtraction of one half cancels the significant digits of p, so the tangent
argument is rounded to +/- pi / 2 and the result saturates at about
+/- 1.633e16 * scale whatever the probability:

    CauchyDistribution.of(0.5, 2).inverseCumulativeProbability(1e-20)
    // -3.266247870639074e16, expected -6.366197723675814e19
    CauchyDistribution.of(0.5, 2).inverseCumulativeProbability(1 - 1e-16)
    // 3.957875932190438e15, expected 5.73416113922266e15

The loss of accuracy starts in the middle of the tail, not just at the
saturation: the value at p = 1e-5 is out by 5e-12 relative (the value at
p = 1e-10 by 5e-7). The function is not even monotonic (successive
probabilities below 1e-18 can return the same value) and the median is off by
a rounding of pi (2.1e-16 relative for the scale 2, location 1.2 test).

Use the equivalent forms tan(pi (p - 1/2)) = -cot(pi p) and
cot(pi (1 - p)) for the lower and upper tail. The cotangent is computed with
1 / tan(x) or cos(x) / sin(x) to avoid the relative error of sin(x) for small
x, and is exactly zero at the median.

Assisted-By: DeepSeek dsv41
Signed-off-by: simpleqt <[email protected]>

Report URL: 
https://github.com/apache/commons-statistics/actions/runs/41906054616

With regards,
GitHub Actions via GitBox

Reply via email to