Repository navigation
Commit 0890f5e
authored
Interval halving switched to the complement (a and b swapped,
y0 = 1 - yy0) once x passed 0.95. For a small yy0 that subtraction
rounds (to exactly 1 for 1e-20), so the target was lost. Switch only
when 1 - yy0 is exact, or to undo an earlier switch, and cap the
unswitched search at 1 - real.epsilon as the switched one already is.
* Fix #11103: switch to the complement unless 1 - yy0 loses yy0
Blocking the switch for every yy0 <= 0.5 made the search stay near 1
without the complement, which lost precision with 64-bit reals:
betaIncompleteInv(1e10, 1, 0.01) gave 0.99999991898 instead of
0.99999999954. Switch as before, and skip it only when 1 - yy0 rounds
away yy0. Drop the 1 - real.epsilon cap: the search now returns
nextDown(1), which is closer, since the CDF there is still below the
probability in the coverage tests.
* Fix #11103: solve for 1 - x when 1 - yy0 loses yy0
Skipping the complement switch kept the search in x near 1, which still
lost precision: betaIncompleteInv(1e11, 1, 1e-6) with 64-bit reals and
(1e12, 1, 0.007) with 80-bit reals were off from the 7th digit. When
1 - yy0 is not exact, bisect t = 1 - x in [1 - x1, 1 - x0] instead, with
betaIncompleteComplSmallX for the CDF, so neither yy0 nor the CDF is
subtracted from 1. As suggested by jmh530.
Signed-off-by: Sarthak <sarthakshreshtha345@gmail.com>
1 parent 3a75e5f commit 0890f5e
1 file changed
Lines changed: 43 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1439 | 1439 | | |
1440 | 1440 | | |
1441 | 1441 | | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
1442 | 1462 | | |
1443 | 1463 | | |
1444 | 1464 | | |
| |||
1562 | 1582 | | |
1563 | 1583 | | |
1564 | 1584 | | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
1565 | 1593 | | |
1566 | 1594 | | |
1567 | 1595 | | |
| |||
1759 | 1787 | | |
1760 | 1788 | | |
1761 | 1789 | | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
1762 | 1800 | | |
1763 | 1801 | | |
1764 | 1802 | | |
| |||
1767 | 1805 | | |
1768 | 1806 | | |
1769 | 1807 | | |
1770 | | - | |
1771 | | - | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
1772 | 1813 | | |
1773 | 1814 | | |
1774 | 1815 | | |
| |||
0 commit comments