# Mean of a half-Cauchy distribution

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$):

Manipulate[
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,
10}]


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).

Best,

Ben

f = 2/(π γ (1 + ((x - x0)/γ)^2))

• Ok, thanks very much for confirming. Any idea why Mathematica's $Mean$ function is not returning this? Best, Ben – ben18785 Jan 6 '16 at 17:49
• 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. – JimB Jan 6 '16 at 17:57
• And this gives you +Infinity: Limit[Mean[TruncatedDistribution[{a, x}, CauchyDistribution[a, 6]]], x -> Infinity]. – JimB Jan 6 '16 at 18:08