diff --git a/doc/distributions/cauchy.qbk b/doc/distributions/cauchy.qbk index e59e3760ed..0b6c53aae1 100644 --- a/doc/distributions/cauchy.qbk +++ b/doc/distributions/cauchy.qbk @@ -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