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

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 iii? Perhaps I need to define aa and bb to be reals.):

i(alog(−a−ib)+iblog(−a−ib)−alog(−a+ib)+iblog(−a+ib))2π(tan−1(ab)π+12)\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 bb, whereby the mean actually decreases and becomes negative (even though the distribution only has support on positive XX):

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

=================

=================

1

=================

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

Ok, thanks very much for confirming. Any idea why Mathematica’s MeanMean function is not returning this? Best, Ben
– ben18785
Jan 6 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.
– Jim Baldwin
Jan 6 at 17:57

And this gives you +Infinity: Limit[Mean[TruncatedDistribution[{a, x}, CauchyDistribution[a, 6]]], x -> Infinity].
– Jim Baldwin
Jan 6 at 18:08