Quantitative Finance Interviews
99

4.6 Order Statistics

Let XX be a random variable with cumulative distribution function FX(x)F_X(x). We can derive the distribution function for the minimum Yn=min⁡(X1,X2,⋯ ,Xn)Y_n=\min(X_1,X_2,\cdots,X_n) and for the maximum Zn=max⁡(X1,X2,⋯ ,Xn)Z_n=\max(X_1,X_2,\cdots,X_n) of nn IID random variables with cdf FX(x)F_X(x) as

P(Yn≥x)=(P(X≥x))n⇒1−FYn(x)=(1−FX(x))n⇒fYn(x)=nfX(x)(1−FX(x))n−1 P(Y_n\ge x)=(P(X\ge x))^n\Rightarrow 1-F_{Y_n}(x)=(1-F_X(x))^n\Rightarrow f_{Y_n}(x)=nf_X(x)(1-F_X(x))^{n-1} P(Zn≤x)=(P(X≤x))n⇒FZn(x)=(FX(x))n⇒fZn(x)=nfX(x)(FX(x))n−1 P(Z_n\le x)=(P(X\le x))^n\Rightarrow F_{Z_n}(x)=(F_X(x))^n\Rightarrow f_{Z_n}(x)=nf_X(x)(F_X(x))^{n-1}

Expected value of max and min

Let X1,X2,⋯ ,XnX_1,X_2,\cdots,X_n be IID random variables with uniform distribution between 0 and 1. What are the cumulative distribution function, the probability density function and expected value of Zn=max⁡(X1,X2,⋯ ,Xn)Z_n=\max(X_1,X_2,\cdots,X_n)? What are the cumulative distribution function, the probability density function and expected value of Yn=min⁡(X1,X2,⋯ ,Xn)Y_n=\min(X_1,X_2,\cdots,X_n)?

Solution: This is a direct test of textbook knowledge. For uniform distribution on [0,1][0,1], FX(x)=xF_X(x)=x and fX(x)=1f_X(x)=1. Applying FX(x)F_X(x) and fX(x)f_X(x) to Zn=max⁡(X1,X2,⋯ ,Xn)Z_n=\max(X_1,X_2,\cdots,X_n) we have

P(Zn≤x)=(P(X≤x))n⇒FZn(x)=(FX(x))n=xn⇒fZn(x)=nfX(x)(FX(x))n−1=nxn−1 \begin{aligned} P(Z_n\le x)=(P(X\le x))^n&\Rightarrow F_{Z_n}(x)=(F_X(x))^n=x^n\\ &\Rightarrow f_{Z_n}(x)=nf_X(x)(F_X(x))^{n-1}=nx^{n-1} \end{aligned} 100

and E[Zn]=∫01xfZn(x)dx=∫01nxndx=nn+1[xn+1]01=nn+1E[Z_n]=\int_0^1 xf_{Z_n}(x)dx=\int_0^1 nx^n dx=\frac{n}{n+1}\left[x^{n+1}\right]_0^1=\frac{n}{n+1}.

Applying FX(x)F_X(x) and fX(x)f_X(x) to Yn=min⁡(X1,X2,⋯ ,Xn)Y_n=\min(X_1,X_2,\cdots,X_n) we have

P(Yn≥x)=(P(X≥x))n⇒FYn(x)=1−(1−FX(x))n=1−(1−x)n⇒fYn(x)=nfX(x)(1−FX(x))n−1=n(1−x)n−1 \begin{aligned} P(Y_n\ge x)=(P(X\ge x))^n&\Rightarrow F_{Y_n}(x)=1-(1-F_X(x))^n=1-(1-x)^n\\ &\Rightarrow f_{Y_n}(x)=nf_X(x)(1-F_X(x))^{n-1}=n(1-x)^{n-1} \end{aligned}

and E[Yn]=∫01nx(1−x)n−1dx=∫01n(1−y)yn−1dx=[yn]01−nn+1[yn+1]01=1n+1E[Y_n]=\int_0^1 nx(1-x)^{n-1}dx=\int_0^1 n(1-y)y^{n-1}dx=\left[y^n\right]_0^1-\frac{n}{n+1}\left[y^{n+1}\right]_0^1=\frac{1}{n+1}.

Correlation of max and min

Let X1X_1 and X2X_2 be IID random variables with uniform distribution between 0 and 1, Y=min⁡(X1,X2)Y=\min(X_1,X_2) and Z=max⁡(X1,X2)Z=\max(X_1,X_2). What is the probability of Y≥yY\ge y given that Z≤zZ\le z for any y,z∈[0,1]y,z\in[0,1]? What is the correlation of YY and ZZ?

Solution: This problem is another demonstration that a figure is worth a thousand words. As shown in Figure 4.7, the probability that Z≤zZ\le z is simply the square with side length zz. So P(Z≤z)=z2P(Z\le z)=z^2. Since Z=max⁡(X1,X2)Z=\max(X_1,X_2) and Y=min⁡(X1,X2)Y=\min(X_1,X_2), we must have Y≤ZY\le Z for any pair of X1X_1 and X2X_2. So if y>zy>z, P(Y≥y∣Z≤z)=0P(Y\ge y\mid Z\le z)=0. For y≤zy\le z, that X1X_1 and X2X_2 satisfies Y≥yY\ge y and Z≤zZ\le z is the square with vertices (y,y),(z,y),(z,z)(y,y),(z,y),(z,z), and (y,z)(y,z), which has an area (z−y)2(z-y)^2. So P(Y≥y∩Z≤z)=(z−y)2P(Y\ge y\cap Z\le z)=(z-y)^2. Hence

P(Y≥y∣Z≤z)={(z−y)2/z2,if 0≤z≤1 and 0≤y≤z0,otherwise. P(Y\ge y\mid Z\le z)=\begin{cases} (z-y)^2/z^2,&\textit{if }0\le z\le 1\textit{ and }0\le y\le z\\ 0,&\textit{otherwise} \end{cases}.

Now let’s move on to calculate the correlation of YY and ZZ.

corr⁡(Y,Z)=cov⁡(Y,Z)std⁡(Y)×std⁡(Z)=E[YZ]−E[Y]E[Z]E[Y2]−E[Y]2×E[Z2]−E[Z]2 \operatorname{corr}(Y,Z)=\frac{\operatorname{cov}(Y,Z)}{\operatorname{std}(Y)\times\operatorname{std}(Z)}=\frac{E[YZ]-E[Y]E[Z]}{\sqrt{E[Y^2]-E[Y]^2}\times\sqrt{E[Z^2]-E[Z]^2}} 101
A unit square with horizontal X₁ and vertical X₂ axes, labeled 0, y, z, and 1. Inside the square of side z, the region excluding the upper-right square from (y,y) to (z,z) is shaded. The four corners of that excluded square are labeled (y,y), (z,y), (y,z), and (z,z).
Figure 4.7 Distribution of X1X_1, X2X_2, their maximum and minimum.

Using previous problem’s conclusions, we have E[Y]=12+1=13E[Y]=\frac{1}{2+1}=\frac{1}{3}, E[Z]=22+1=23E[Z]=\frac{2}{2+1}=\frac{2}{3}. From the pdfs of YY and ZZ, fYn(x)=n(1−x)n−1=2(1−x)f_{Y_n}(x)=n(1-x)^{n-1}=2(1-x) and fZ(z)=nzn−1=2zf_Z(z)=nz^{n-1}=2z, we can also get E[Yn2]=∫012(1−y)y2dy=23−24=16E[Y_n^2]=\int_0^1 2(1-y)y^2dy=\frac{2}{3}-\frac{2}{4}=\frac{1}{6} and E[Zn2]=∫012z3dz=24E[Z_n^2]=\int_0^1 2z^3dz=\frac{2}{4}, which give us the variances: var⁡(Y)=E[Y2]−E[Y]2=16−(13)2=118\operatorname{var}(Y)=E[Y^2]-E[Y]^2=\frac{1}{6}-\left(\frac{1}{3}\right)^2=\frac{1}{18} and var⁡(Z)=24−(23)2=118\operatorname{var}(Z)=\frac{2}{4}-\left(\frac{2}{3}\right)^2=\frac{1}{18}.33

To calculate E[YZ]E[YZ], we can use E[YZ]=∫01∫0zyzf(y,z)dydzE[YZ]=\int_0^1\int_0^z yzf(y,z)dydz. To solve this equation, we need f(y,z)f(y,z). Let’s again go back to Figure 4.7. From the figure we can see that when 0≤z≤10\le z\le1 and 0≤y≤z0\le y\le z, F(y,z)F(y,z) is the shadowed area with probability

F(y,z)=P(Y≤y∩Z≤z)=P(Z≤z)−P(Y≥y∩Z≤z)=z2−(z−y)2=2zy−y2 F(y,z)=P(Y\le y\cap Z\le z)=P(Z\le z)-P(Y\ge y\cap Z\le z)=z^2-(z-y)^2=2zy-y^2 ∴f(y,z)=∂∂y∂zF(y,z)=2 and E[YZ]=∫01∫0z2yzdydz=∫00z[y2]0zdz=∫01z3dz=14. \therefore f(y,z)=\frac{\partial}{\partial y\partial z}F(y,z)=2\text{ and }E[YZ]=\int_0^1\int_0^z 2yzdydz=\int_0^0 z[y^2]_0^z dz=\int_0^1 z^3 dz=\frac{1}{4}. 102

An alternative and simpler approach to calculate E[YZ]E[YZ] is again to take advantage of symmetry. Notice that no matter x1≤x2x_1\le x_2 or x1>x2x_1>x_2, we always have yz=x1x2yz=x_1x_2 (z=max⁡(x1,x2)z=\max(x_1,x_2) and y=min⁡(x1,x2)y=\min(x_1,x_2)).

∴E[YZ]=∫01∫01x1x2dx1dx2=E[X1]E[X2]=12×12=14. \therefore E[YZ]=\int_0^1\int_0^1 x_1x_2dx_1dx_2=E[X_1]E[X_2]=\frac{1}{2}\times\frac{1}{2}=\frac{1}{4}.

Hence cov⁡(Y,Z)=E[YZ]−E[Y]E[Z]=136\operatorname{cov}(Y,Z)=E[YZ]-E[Y]E[Z]=\frac{1}{36} and corr⁡(Y,Z)=cov⁡(Y,Z)var⁡(Y)×var⁡(Z)=12\operatorname{corr}(Y,Z)=\frac{\operatorname{cov}(Y,Z)}{\sqrt{\operatorname{var}(Y)}\times\sqrt{\operatorname{var}(Z)}}=\frac{1}{2}.

Sanity check: That YY and ZZ have positive autocorrelation make sense since when YY becomes large, ZZ tends to become large as well (Z≥YZ\ge Y).

Random ants

500 ants are randomly put on a 1-foot string (independent uniform distribution for each ant between 0 and 1). Each ant randomly moves toward one end of the string (equal probability to the left or right) at constant speed of 1 foot/minute until it falls off at one end of the string. Also assume that the size of the ant is infinitely small. When two ants collide head-on, they both immediately change directions and keep on moving at 1 foot/min. What is the expected time for all ants to fall off the string?34

Solution: This problem is often perceived to be a difficult one. The following components contribute to the complexity of the problem: The ants are randomly located; each ant can go either direction; an ant needs to change direction when it meets another ant. To solve the problem, let’s tackle these components.

When two ants collide head-on, both immediately change directions. What does it mean? The following diagram illustrates the key point:

Before collision: Ant A moves right and ant B moves left, toward each other.; After collision: Ant A moves left and ant B moves right, away from each other.; switch label: After switching labels, B moves left and A moves right, continuing their original directions.

When an ant AA collides with another ant BB, both switch direction. But if we exchange the ants’ labels, it’s like that the collision never happens. AA continues to move to the right and BB moves to the left. Since the labels are randomly assigned anyway, collisions make no difference to the result. So we can assume that when two ants meet, each just keeps on going in its original direction. What about the random direction that each ant chooses? Once the collision is removed, we can use symmetry to argue that it makes no difference which direction that an ant goes either. That means if an ant is put at the xx-th foot, the 103expected value for it to fall off is just xx min. If it goes in the other direction, simply set xx to 1−x1-x. So the original problem is equivalent to the following:

What is the expected value of the maximum of 500 IID random variables with uniform distribution between 0 and 1?

Clearly the answer is 499500\frac{499}{500} min, which is the expected time for all ants to fall off the string.