Find mean of the minimum of N uniformly distributed random variables

I want to find the mean of the minimum of N uniformly distributed random variables. I used to the following code to find it for two random variables X1 and X2

a = 0; b = 1; Num = 1000000;
X1 = RandomReal[UniformDistribution[{a, b}], Num];
X2 = RandomReal[UniformDistribution[{a, b}], Num];
W = Table[Min [X1[[i]], X2[[i]]], {i, 1, Num}];
Print["The mean for the minimum set is ", Mean[W]]

Hi Bilal,

Here is one way to do it

n = 2;
Table[RandomReal[UniformDistribution[{a, b}], Num], n] // MapThread[Min, #] & // Mean

Mean[OrderDistribution[{UniformDistribution[{a, b}], n}, 1]] // FullSimplify
(* (b + a n)/(1 + n) *)

I get the following error when I used your code, any idea?

I need to find the Mean of the minimum of N uniformly distributed random variables, does your answer include that?

It should work fine. Please post code, not an image so we can run exactly what you ran. The image shows boxes for // what is that?

a = 0; b = 1; Num = 1000000; n = 2;
Table[RandomReal[UniformDistribution[{a, b}], Num], n] //
MapThread[Min, #] & // Mean

This is the code I used

That is exactly what my answer is.

Thank you, what about the maximum?

I cut and pasted that code and it ran without any errors.

That’s strange, I tried it again and the same error occurred. I am running it on a old version of Mathematica (9.0) , maybe that is the problem.

I’ll try it on another Mathematica version. Which version do you have?

The documentation will tell you to change the 1 to n in the code I gave to get the maximum. (For a Uniform distribution there’s no need to perform simulations with a specific sample size. There is an exact answer for a general sample size.)