I have the following information: $\left[ \begin{array}{l} {X_1}\\ \vdots \\ {X_K} \end{array} \right]$ are correlated random variables with (zero mean, unit variance) covariance matrix $\left( {\begin{array}{*{20}{c}} 1& \ldots &{\rho _{1K}^X}\\ \vdots & \ddots & \vdots \\ {\rho _{K1}^X}& \cdots &1 \end{array}} \right)$, and $\left[ \begin{array}{l} {Y_1}\\ \vdots \\ {Y_K} \end{array} \right]$ are correlated random variables with covariance matrix $\left( {\begin{array}{*{20}{c}} 1& \ldots &{\rho _{1K}^Y}\\ \vdots & \ddots & \vdots \\ {\rho _{K1}^Y}& \cdots &1 \end{array}} \right)$. Moreover, $X_i$ and $Y_i$ is also correlated with correlation coefficient $\rho_i$.
Can someone please give me some hints how to generate X and Y? Thank you very much.
Assuming the variable $X_i$ is correlated with $Y_j$ with coefficient $\rho_{ij}^{XY}$. Call $Z$ the vector containing $X$ for the first $K$ components and $Y$ for the next $K$. Then the covariance matrix of $Z$ will be:
$$\mathbf{\Sigma_Z} = \begin{bmatrix} \Sigma_X & \Sigma_{XY} \\ \Sigma_{XY} & \Sigma_Y \end{bmatrix}$$
$$\mathbf{\Sigma_X}=\left( {\begin{array}{*{20}{c}} 1& \ldots &{\rho _{1K}^X}\\ \vdots & \ddots & \vdots \\ {\rho _{K1}^X}& \cdots &1 \end{array}} \right)$$
$$\mathbf{\Sigma_Y}=\left( {\begin{array}{*{20}{c}} 1& \ldots &{\rho _{1K}^Y}\\ \vdots & \ddots & \vdots \\ {\rho _{K1}^Y}& \cdots &1 \end{array}} \right)$$
$$\mathbf{\Sigma_{XY}}=\left( {\begin{array}{*{20}{c}} {\rho _{11}^{XY}}& \ldots &{\rho _{1K}^{XY}}\\ \vdots & \ddots & \vdots \\ {\rho _{K1}^{XY}}& \cdots &{\rho _{KK}^{XY}} \end{array}} \right)$$