# Intuition behind Gaussian copula and its simulation algorithm

My question is related to the answer in this post.

The definition of the Gaussian copula is easy to understand and the simulation algorithm as well, but I do not see how does the two relate.

My question is why does the following algorithm (where $P$ is a correlation matrix)

1. Perform a Cholesky decomposition of $P$, and set $A$ as the resulting lower triangular matrix.
2. Repeat the following steps $n$ times.
1. Generate a vector $Z = (Z_1, \ldots, Z_d)'$ of independent standard normal variates.
2. Set $X = AZ$
3. Return $U = (\Phi(X_1), \ldots, \Phi(X_d))'$.

Simulates the Gaussian copula

$$C_P(u_1, \ldots, u_d) = \boldsymbol{\Phi}_P(\Phi^{-1}(u_1), \ldots, \Phi^{-1}(u_d))$$

What is the intuition that explains why that algorithm works to simulate the copula?

In addition, is there a link between $U$ obtained in step 2.3 and $(u_1,...,u_d)$ in $C_p$? If so, what is it?

I am simply trying to understand why the two relate. There is no need to explain what the algorithm does nor what a copula is.

$$\text{Var}(AZ) = A \text{Var}(Z) A^\top = AIA^\top = P$$
At step 3 you produce uniform marginals by transforming each marginal to standard uniform (because $$F_X(X)\sim U(0,1)$$); transforming marginals has no effect on the copula. At this point we have samples from a multivariate distribution whose dependence is given by the correct copula and which has uniform marginals. That is, we are sampling from the copula.
The $$u$$'s in the copula function are effectively just arguments, so that you can see where you are in the function (consider $$F_Z(z)=P(Z\leq z)$$ by comparison -- $$z$$ is just where you're evaluating $$F$$; $$Z$$ is the random variable); but the $$U$$'s that they "carry" the copula of are certainly related to the U's in the algorithm in that the random U's in the algorithm are realizations of those random variables.