Empirical mean excess plot of (μ, e(μ))
Spit-balling a little here, based on my best understanding of your definition:
n = 500;
variates = RandomVariate[CauchyDistribution[], n];
ClearAll[meanExcess]
meanExcess[data_, mu_] :=
Total[#]/Length[#]& @ Cases[data, x_?(# > mu &) :> x - mu]
Plot[meanExcess[variates, mu], {mu, 0, 10}]
Three additional ways to implement empirical mean excess using
TruncatedDistribution
+EmpiricalDistribution
UnitStep
+Pick
Clip
+DeleteCases
ClearAll[eme1, eme2, eme3]
eme1[data_, μ_] := Mean @ TruncatedDistribution[{μ, ∞}, EmpiricalDistribution @ data]
eme2[data_, μ_] := Mean @ Pick[data, UnitStep[data - μ], 1]
eme3[data_, μ_] := Mean @ DeleteCases[Null] @ Clip[data, {μ, ∞}, {Null, ∞}]
Examples:
SeedRandom[1]
rv = RandomVariate[CauchyDistribution[], 100];
Verify that all three methods give the same result when the threshold parameter is within the sample range:
Max @ Chop[{Norm[eme1[rv, #] - eme2[rv, #]],
Norm[eme1[rv, #] - eme3[rv, #]],
Norm[eme2[rv, #] - eme3[rv, #]]} & /@ RandomReal[MinMax[rv], 500]]
0
Plot[{eme1[rv, x], eme2[rv, x], eme3[rv, x]}, {x, 0, 10},
PlotStyle -> {Directive[AbsoluteThickness[7], Red],
Directive[AbsoluteThickness[3], Blue], Directive[Thin, Green]},
ImageSize -> Large, PlotLegends -> {"eme1", "eme2", "eme3"}]