# Simulation of joint random variables

I'm reviewing simulation methods, and I've come across a problem on simulating a joint distribution, where I'm unsure of on how to proceed.

Problem: Let $X$ and $Y$ be random variables with $f(x) = \frac{1}{x^2 - x}$, $x = 2,3,4,5, \dots$ and $Y \sim \text{Exponential}(\lambda = x)$. Create an algorithm to simulate the vector (X,Y).

So far: A hint was to use the inverse transform method (ITM) on $X$ first. To find $F(x)$:

$$F(x) = \sum\limits_{i=2}^n \frac{1}{i^2 - i} = \frac{n-1}{n}.$$

Let $U \sim \text{Uniform}(0,1)$. Then $F^{-1}(U) = n = \frac{1}{1-U}$. So, we can simulate $X$ with

1. Generate $U \sim \text{Uniform}(0,1)$.
2. Set $X = \frac{1}{1-U}$.

However, I'm not entirely sure how this helps. Don't we need to find the joint cdf? I know how to simulate $Y$ using the ITM separately too...

• Once you simulate $X$, draw a random value $Y$ from the Exponential distribution with parameter $\lambda = X$. Sep 15, 2017 at 14:30
• Should it be $f(x) = \frac{1}{x^2-x},$ for $x = 2, 3, 4...?$. Also if $U^\prime \sim \mathsf{Unif}(0,1),$ then $U = 1-U^\prime \sim \mathsf{Unif}(0,1),$ so you can use $Y = -\ln U.$ to get $Y \sim \mathsf{Exp}(1).$ Sep 16, 2017 at 0:49

Your procedure won't give a valid sample of $X$ ($\frac{1}{1-U}$ will not be an integer with probability 1).
In order to generate a sample from $X$, let $F(x) = P(X \leq x)$ be the CDF of $X$. Generate a sample from the (continuous) uniform distribution $U$ on the interval [0,1]. Then, generate your sample of $X$, $x$, to be the smallest value in $2, 3, 4, \ldots$ such that $U \leq F(x)$. You can calculate this value of $x$ easily from the closed form of CDF you have, along with appropriate rounding.
In other words, we re-define the inverse CDF a bit to be $F^{-1}(u) = \min \{x: F(x) \geq u\}$. Then, we see that $F^{-1}(U)$ where $U$ is Uniform[0,1] is distributed as $X$, even if $X$ is discrete valued (you can see this definition of $F^{-1}$; for a continuous distribution given by $F$, this agrees with the usual definition of inverse).
Then, take your sample of $X$, $x$, and generate an exponential random variable $Y$. By inverse transform sampling, you can do this by generating a Uniform[0,1] random variable $V$, and outputing a sample of $Y$ an $-\frac{\log V}{x}$.
• For your method for simulating $X$ first, is this still the ITM in a traditional sense though? Seems that we cannot simply let $X = F^{-1}(U)$ for this case. Instead, we use the method as you have presented, which works perfect. Sep 16, 2017 at 6:30