Simulation of P(X + Y < 1) in matlab

51 Views Asked by At

I am trying to solve the following problem, but I do not know how to go about it.

Let $X \sim \mathcal{U}(0;1)$ and $Y \sim \mathcal{Exp}(1)$ be independent. Simulate in MATLAB how you can find the probability $\mathbb{P}[X + Y < 1]$.

Thank you.

1

There are 1 best solutions below

1
On BEST ANSWER

I think you have learned that $-\ln(U)$ where $U$ is uniform on $(0;1)$ follows an $\mathcal{Exp}(1)$ law. Therefore, it will be a privilegized way to simulate such a distribution.

Here is a Matlab program that gives the result :

n=100000;
X=rand(1,n);
Y=-log(rand(1,n));
Z=X+Y;
U=Z<1;
P=mean(U)
hist(Z,60);% optional !

($Z$ is a boolean array with entries $0$ (resp. $1$) if the condition is not fulfilled (resp. fulfilled) ; the number of "ones" is the number of successes).

The numerical result $P \approx 0.3678$ coincides very well with the theoretical result $e^{-1}$...

... that can be computed using the underlying density of Random Variable $Z=X+Y$ which is the convolution of the densities of $X$ and $Y$, i.e. :

$$(\text{for} \ x>0) : \ \ f_Z(x)=e^{-x}(e^{-min(x,1)}-1)$$

Here is a histogram of the simulation of $Z$ :

enter image description here