Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
Hi; There is backslash "\" in front of [Distributed]. –  bobbym Jan 4 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? –  Nasser Jan 4 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. –  bobbym Jan 4 at 10:02
If you format your question according to the editing help backslashes won't disappear. –  Sjoerd C. de Vries Jan 4 at 10:10
Hi; Thanks for editing it. In the future I will try to do a better job. –  bobbym Jan 4 at 19:03
add comment

2 Answers 2

up vote 4 down vote accepted

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 *)
share|improve this answer
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. –  bobbym Jan 4 at 19:05
add comment

Here's what you want:

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

(* 9/5 *)
share|improve this answer
Thanks for that solution. –  bobbym Jan 4 at 19:06
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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