I am trying to calculate the mean (if it exists) of a half-Cauchy distribution. I know that the mean of the a Cauchy is undefined, but I was wondering whether the same is true of a half-Cauchy? (A half-Cauchy is a Cauchy that is truncated to only have support for positive $X$).

At the moment I have been doing the following:

Mean@TruncatedDistribution[{0, \[Infinity]}, CauchyDistribution[a, b]]

which returns the following (not sure why it involves $i$? Perhaps I need to define $a$ and $b$ to be reals.):

$\frac{i (a \log (-a-i b)+i b \log (-a-i b)-a \log (-a+i b)+i b \log (-a+i b))}{2 \pi \left(\frac{\tan ^{-1}\left(\frac{a}{b}\right)}{\pi }+\frac{1}{2}\right)}$

If I plot the half-Cauchy and its mean, then I get quite an odd result as I increase $b$, whereby the mean actually decreases and becomes negative (even though the distribution only has support on positive $X$):

 Module[{aDist = 
TruncatedDistribution[{0, \[Infinity]}, CauchyDistribution[a, b]],
aMean}, aMean = Mean@aDist; 
Plot[PDF[aDist, x], {x, -3, 10}, PlotRange -> Full, 
  Epilog -> Line[{{aMean, 0}, {aMean, 10}}]]], {a, 0, 10}, {b, 1, 

Does anyone know what this might be happening? Is the expression correct, or is it a mirage? (I'm guessing it's to do with the fat tails of this distribution that mean that its integral is not well-defined, but am not sure).




The mean does not exist for a half Cauchy. You can verify that more directly with the following:

f = 2/(π γ (1 + ((x - x0)/γ)^2))
Integrate[f , {x, x0, Infinity}, Assumptions -> {x0 ∈ Reals, γ ∈ Reals, γ > 0}]
Integrate[f x, {x, x0, Infinity}, Assumptions -> {x0 ∈ Reals, γ ∈ Reals, γ > 0}]

with output


  • $\begingroup$ Ok, thanks very much for confirming. Any idea why Mathematica's $Mean$ function is not returning this? Best, Ben $\endgroup$ – ben18785 Jan 6 '16 at 17:49
  • $\begingroup$ I wish I knew. Using one of the examples in TruncatedDistribution I tried Mean[TruncatedDistribution[{-\[Infinity], 0.5}, CauchyDistribution[0, 1]]] but it just returns the command. However, Median[TruncatedDistribution[{-\[Infinity], 0.5}, CauchyDistribution[0, 1]]] returns -0.618034. $\endgroup$ – JimB Jan 6 '16 at 17:57
  • $\begingroup$ And this gives you +Infinity: Limit[Mean[TruncatedDistribution[{a, x}, CauchyDistribution[a, 6]]], x -> Infinity]. $\endgroup$ – JimB Jan 6 '16 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.