sergazy.nurbavliyev@gmail.com © 2021

## Minimum of two random variables

Question: Assume we have $X \sim Uniform(0, 1)$ and $Y \sim Uniform(0,1)$ and independent of each other. What is the expected value of the minimum of $X$ and $Y$?


### Intuition

Before going to show the exact theoretical result, we can think heuristically,we have two uniform random variables  that are independent of each other, we would expect two of these random variables to divide the interval (0,1) equally into 3 equal subintervals. Then the minimum would occur at 1/3 and the other one (which is maximum in this case) occurs at 2/3. We can even generalize our intuition for $n$ independent uniform random variables. In that case minimum would occur at $1/(n+1)$ and maximum would occur at $n/(n+1)$. Now let us verify intution theoretically. 

### Theoritical result

Let $Z$  be minimum of X and Y. We write this as $Z=\min(X,Y)$. 
\begin{equation}
\mathbb{P}(Z\leq z)= \mathbb{P}(\min(X,Y)\leq z) =1-\mathbb{P}(\min(X,Y)\geq z)=1-\mathbb{P}(X> z, Y>z)
\end{equation}
Since our distribution is between 0 and 1 the following is true for uniform distribution
\begin{equation}
\mathbb{P}(X\leq z)= z \text{ and } \mathbb{P}(X> z)=1- z 
\end{equation}
Also same goes for $Y$. Now since they are independent we have
\begin{equation}
\mathbb{P}(X> z, Y>z)=\mathbb{P}(X> z)\mathbb{P}(Y>z)=(1-z)^{2}
\end{equation}
Then equation (1) becomes
\begin{equation}
\mathbb{P}(Z\leq z)=1-\mathbb{P}(X> z, Y>z)=1-(1-z)^{2}
\end{equation}
We just calculated cumulative distribution function of $z$. Usually denoted as 
\begin{equation}
F_{Z}(z)= \mathbb{P}(Z\leq z)
\end{equation}
If we take derivative of this $ F_{Z}(z)$, we will get density function of z. In this case it would be
\begin{equation}
F_{Z}'(z)=f_Z(z)=2(1-z)
\end{equation}
As last part we would take integral of $zf_Z(z)$ between 0 and 1 to find an expected value of minimum of two uniform random variables.
\begin{equation}
\mathbb{E}[Z]=\int_{0}^1 zf_Z(z)dz=\int_{0}^1 2z(1-z)dz=2\left(\frac{1}{2}-\frac{1}{3}\right)=\frac{1}{3}
\end{equation}


```python
# If you are allowed to use any programming language then you can simulate.
import numpy as np
x = np.random.uniform(0,1,100000)
y = np.random.uniform(0,1,100000)
z =np.minimum(x,y)
u =np.maximum(x,y)
```


```python
np.mean(z), np.mean(u) # as you can see z is very close to 1/3
```




    (0.33389155844548174, 0.6670118602826249)



### To see the histogram of Z and U


```python
import matplotlib.pyplot as plt
count, bins, ignored = plt.hist(z, 100, density=True)
plt.plot(bins, np.ones_like(bins), linewidth=2, color='r')
plt.show()
```


```python
import matplotlib.pyplot as plt
count, bins, ignored = plt.hist(u, 100, density=True)
plt.plot(bins, np.ones_like(bins), linewidth=2, color='r')
plt.show()
```


```python

```


```python

```

7792f22eb5df8b0c22b46aea714021ab8940af42
ipynb
Jupyter Notebook
Minimim of two random variables March 3 2021.ipynb
sernur/probability_stats_interveiw_questions
3144dae00fa83c82ff4e1f7668828349270a1937
MIT
2021-03-04T06:48:28.000Z
2021-04-19T10:04:24.000Z
Minimim of two random variables March 3 2021.ipynb
sernur/probability_stats_interveiw_questions
3144dae00fa83c82ff4e1f7668828349270a1937
MIT
2021-03-05T22:00:43.000Z
2021-03-05T22:00:43.000Z
Minimim of two random variables March 3 2021.ipynb
sernur/probability_stats_interveiw_questions
3144dae00fa83c82ff4e1f7668828349270a1937
MIT
2021-03-04T05:02:00.000Z
2021-03-16T01:13:40.000Z
Qwen/Qwen-72B
1. YES
2. YES