Skip to content

Commit

Permalink
Merge pull request #1237 from WarrenWeckesser/doc-cauchy-cdf
Browse files Browse the repository at this point in the history
DOC: Update description of the Cauchy cdf and its complement.
  • Loading branch information
mborland authored Jan 23, 2025
2 parents 2f3c798 + 742b5cc commit 61b87df
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions doc/distributions/cauchy.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 61b87df

Please sign in to comment.