# Expected sum of largest 3

I pick 4 numbers from the Uniform Distribution. I need the expected value of the sum of the 3 largest. I am pretty sure that the answer is 9 / 5 which agrees with a simulation. I would like to get mathematica to do this. I have tried this:

Assuming[a >= b >= c >= d,
Expectation[a + b + c, {a, b, c, d} \[Distributed] UniformDistribution[{{0, 1},{0, 1}, {0, 1}, {0, 1}}]]]


which returns 3 / 2. What am I doing wrong?

• Hi; There is backslash "\" in front of [Distributed]. Jan 4, 2014 at 9:39
• I am not good in probability at all. But isn't expectation a linear operation? So E[a+b+c]=E[a]+E[b]+E[c], and since E[*]=1/2 since it is Uniform{0,1}, and no drawing was biased in any way, then the result is 1.5, why would it be 1.8 as you say? Jan 4, 2014 at 9:55
• Hi Nasser; It is because you are not just picking 3 numbers randomly from that distribution, you are picking 4 and choosing to add the 3 largest of the 4. This skews it above the mean since the smallest value is never used. Jan 4, 2014 at 10:02
• If you format your question according to the editing help backslashes won't disappear. Jan 4, 2014 at 10:10
• Hi; Thanks for editing it. In the future I will try to do a better job. Jan 4, 2014 at 19:03

You could compute the expectation of a + b + c + d - Min[a, b, c, d]:

Expectation[a + b + c + d - Min[a, b, c, d],
{a, b, c, d} \[Distributed] UniformDistribution[{{0, 1}, {0, 1}, {0, 1}, {0, 1}}]]

(* 9/5 *)


Or you could use OrderDistribution

With[{f = OrderDistribution[{UniformDistribution[], 4}, #] &},
Expectation[a + b + c,
{a \[Distributed] f[4], b \[Distributed] f[3], c \[Distributed] f[2]}]]

(* 9/5 *)

• Hi; I knew about the idea of using the minimum, I was hoping for an order statistic solution just like the one you and rasher provided. Thanks much. Jan 4, 2014 at 19:05
• Umm -- the solution given here using OrderDistribution is correct by chance, but the approach is not actually valid. In particular, it defines a as the distribution of the largest order statistic, b as the second largest ... etc ... each univariate ... BUT what is actually needed is the joint pdf of $(a,b,c)$ ... not the marginal pdfs of a, b and c. The solution happens to work in this particular instance, not because the method is correct, but because $E[a + b + c] = E[a] + E[b] + E[c]$. By contrast, the proposed method would give the wrong answer for: Expectation[a b c, etc] Aug 10, 2014 at 17:31

Here's what you want:

Expectation[
x1 + x2 + x3 + x4, {x1, x2, x3, x4} \[Distributed]
ProductDistribution[{UniformDistribution[], 4}]] -
Expectation[x,
x \[Distributed] OrderDistribution[{UniformDistribution[], 4}, 1]]

(* 9/5 *)


Another way to use OrderDistribution: use the joint distribution of largest three order statistics in a sample of size four:

dist = OrderDistribution[{UniformDistribution[], 4}, {2, 3, 4}];
Expectation[x + y + z, {x, y, z} \[Distributed] dist]
(* 9/5 *)