Plot correlation between two dependent variables by generating samples from conditional CDF I'm trying to understand the correlation between dependent variables $Y_{n+1}$ and $Y_n$ and was thinking of plotting the pair $(Y_n, Y_{n+1})$. I have a complicated CDF which looks like:
$$P(Y_{n+1} \leq y \mid Y_n = y_n ) = h(y, y_n)$$
where $h$ is some function. In order to plot the correlation, I would require sample pairs $(Y_n, Y_{n+1})$ generated from this conditional CDF. I was thinking of using inverse transform method to generate the samples but I'm facing two difficulties: first, assuming that I fix some arbitrary $Y_n$, the CDF itself is complicated enough that obtaining a closed form won't be possible in which case, how can I numerically evaluate the inverse CDF and generate samples of $Y_{n+1}$ for every fixed $Y_n$. And secondly, I have a huge doubt on if this is the right way to generate samples in such a way. But, the final goal is to see the correlation between $Y_{n+1}$ and $Y_n$. Any simulation example showing this would be tremendously helpful.
Thanks a lot!
 A: $\newcommand{\cov}{\operatorname{cov}}$\begin{align}
& \cov(Y_n, Y_{n+1}) \\[8pt]
= {} & \cov(Y_n, Y_{n+1}-Y_n) + \cov(Y_n, Y_n)
\end{align}
The second term is the variance of $Y_n.$
\begin{align}
& \cov(Y_n,\, Y_{n+1} -Y_n) \\[8pt]
= {} & \operatorname E(\cov(Y_n,\,Y_{n+1}-Y_n\mid Y_n)) + \cov(\operatorname E(Y_n\mid Y_n), \operatorname E(Y_{n+1}-Y_n\mid Y_n)) \\[8pt]
= {} & \operatorname E(0) + \cov(Y_n, \operatorname E(Y_{n+1}-Y_n\mid Y_n))
\end{align}
The first term is $0$ because when one conditions on $Y_n$, then  $Y_n$ becomes a constant, so it's covariance with anything is $0.$
Now the question is how, if at all, $\operatorname E(Y_{n+1}-Y_n\mid Y_n)$ depends on $Y_n.$ We have
$$
\operatorname E(Y_{n+1}-Y_n\mid Y_n) = \int\limits_{\mathbb R} (y - y_n) \cdot \frac{\partial h(y,y_n)}{\partial y} \, dy.
$$
One often considers situations like this in which the conditional distribution of $Y_{n+1}-Y_n$ given $Y_n$ does not depend on $Y_n,$ i.e. the amounts added at each step are independent of each other. In that case, that last covariance considered is $0.$ And in such a case, the variance of $Y_n$ is just the sum of the variances of the differences, provided we assume $\Pr(Y_0=0)=1.$ In that case you would have $\operatorname{var}(Y_n) = n\operatorname{var}(Y_1),$ and so the correlation that you seek would be
$$
\operatorname{cor}(Y_n,Y_{n+1}) = \frac{\cov(Y_n, Y_{n+1})}{\operatorname{sd}(Y_n) \operatorname{sd}(Y_{n+1})} = \frac{n\operatorname{var}(Y_1)}{\sqrt{n\operatorname{var}(Y_1)}\cdot\sqrt{(n+1)\operatorname{var}(Y_1)}}
$$
and $\operatorname{var}(Y_1)$ cancels out.
