2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Merge pull request #1237 from WarrenWeckesser/doc-cauchy-cdf

DOC: Update description of the Cauchy cdf and its complement.
This commit is contained in:
Matt Borland
2025-01-23 14:00:28 -05:00
committed by GitHub

View File

@@ -105,28 +105,23 @@ In the following table __x0 is the location parameter of the distribution,
[table
[[Function][Implementation Notes]]
[[pdf][Using the relation: ['pdf = 1 / ([pi] * [gamma] * (1 + ((x - __x0) / [gamma])[super 2]) ]]]
[[pdf][Using the relation: ['pdf = 1 / ([pi] * [gamma] * (1 + ((x - __x0) / [gamma])[super 2])) ]]]
[[cdf and its complement][
The cdf is normally given by:
[expression p = 0.5 + atan(x)/[pi]]
But that suffers from cancellation error as x -> -[infin].
So recall that for `x < 0`:
[expression atan(x) = -[pi]/2 - atan(1/x)]
Instead, the mathematically equivalent expression based on the function atan2
is used:
Substituting into the above we get:
[expression p = atan2(1, -x)/[pi]]
[expression p = -atan(1/x) / [pi] ; x < 0]
By symmetry, the complement is
So the procedure is to calculate the cdf for -fabs(x)
using the above formula. Note that to factor in the location and scale
parameters you must substitute (x - __x0) / [gamma] for x in the above.
[expression q = atan2(1, x)/[pi]]
This procedure yields the smaller of /p/ and /q/, so the result
may need subtracting from 1 depending on whether we want the complement
or not, and whether /x/ is less than __x0 or not.
]]
[[quantile][The same procedure is used irrespective of whether we're starting
from the probability or its complement. First the argument /p/ is