Order Statistics

Demonstration

Random sample of size n=5 from a standard normal distribution:

xVals=RandomVariate[NormalDistribution[],5]

Here is the min of the random sample:

Min[xVals]

Here is the max of the random sample:

Max[xVals]

Here is the second-smallest value in the random sample:

Sort[xVals][[2]]

Problem 1

Generate 10,000 random samples, each of size 2, from the Exp((1/10)) distribution:

xVals=RandomVariate[ExponentialDistribution[1/10],{10000,2}]

The distribution of the minimum values in each sample:

minVals=Min/@xVals

Show[Histogram[minVals,Automatic,"PDF"],Plot[PDF[ExponentialDistribution[1/5],x],{x,0,20}]]

Mean[minVals]

The distribution of the maximum values in each sample:

maxVals=Max/@xVals;
Histogram[maxVals,Automatic,"PDF"]

Mean[maxVals]

Plot of the pdf of min((Subscript[X, 1]),(Subscript[X, 2])) in blue, and the pdf of max((Subscript[X, 1]),(Subscript[X, 2])) in orange.

Plot[{Exp[-y/5]/5,(Exp[-y/10]-Exp[-y/5])/5},{y,0,30}]

Expected value of max((Subscript[X, 1]),(Subscript[X, 2])):

Integrate[y/5 (Exp[-y/10]-Exp[-y/5]),{y,0,Infinity}]

Problem 2

xVals=RandomVariate[ExponentialDistribution[1/10],{10000,3}];

medVals=Median/@xVals;

Histogram[medVals]

Mean[medVals]

This is close to the true median of (25/3).

Problem 3

Here is the integral that gives P((1/4)<(Subscript[Y, 2])<(3/4)):

Integrate[6y(1-y),{y,1/4,3/4}]

Problem 4

Here is the pdf of the sample median for a sample of size n:

g[n_,y_]:=Factorial[n](y(1-y))^((n-1)/2)/(Factorial[(n-1)/2]^2)

For example, if n=3, we get the same function as in Problem 3:

g[3,y]

Here is the pdf if n=5:

g[5,y]

Now compute (∫_0.4^0.6)g[n,y]dy for n=3,5,7,...,15:

Table[
Integrate[g[n,y],{y,0.4,0.6}],
{n,3,15,2}]

Here is a plot of the densities of the sample means for  n=3,5,7,...,15. As n gets larger, the density is more concentrated near y=(1/2).

pdfs=Table[g[n,y],{n,3,21,2}]
Plot[pdfs,{y,0,1}]

Problem 5

Plot of all eight order statistics of iid Unif[0,1] random variables (Subscript[X, 1]),...,(Subscript[X, 8]):

n=8;
pdfs =Table[n!/((i-1)!(n-i)!)y^(i-1)(1-y)^(n-i),{i,1,n}]

Plot[pdfs,{y,0,1}]

Expected value of the order statistics:

Table[Integrate[y*n!/((i-1)!(n-i)!)y^(i-1)(1-y)^(n-i),{y,0,1}],{i,1,8}]