-1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Something like: take a large sample of $X$; take a similarly large sample of $Y$; add them together pointwise; find the proportion of the sums that are less than $1$. In R you could try something like X<-runif(10^6);Y<-rexp(10^6,1);mean(X+Y<1) $\endgroup$ – Henry Mar 26 at 1:36
0
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Thanks, makes sense. $\endgroup$ – FilipPPPILA Mar 27 at 4:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.