1

Generate a Sample $\underline{Z_1}$ $\underline{Z_2}\dots \underline{Z_{5000}}$ , while $\underline{Z_i} \sim N_2[(0,0)^T,I_2]$

generate new sample with size of $ n = 5000$ by applying linear transformation on $\underline{Z_i}$

$\underline{X_1}$ $\underline{X_2}\dots \underline{X_{5000}}$ , while $\underline{X_i} \sim N_2[(1,2)^T,\begin{pmatrix}2&1.5\\ 1.5&2\end{pmatrix}]$.

My attempt:

n1 <- 5000
mu <- c(0,0)
sigma <- diag(2)
y2 <- mvrnorm(n1,mu,sigma)

I have generated the first sample but aside from that , I have no idea how to continue..

Update $X = A*Z + \mu$ while $\mu = (1,2)^T.$

To find $A$ we use this equation $\Sigma = A*A^T$.

ed = eigen(Sigma)
A = ed$vectors %*% diag(sqrt(ed$values))

but still I'm not getting the right value for $A$.

because $A*A^T\neq \Sigma$.

Mahajna
  • 53
  • 4

1 Answers1

2

Say we want to sample $x$ from $N(a,b)$. We could certainly do this in R using rnorm(a,b). However, we could also sample $z$ from $N(0,1)$ and apply the linear transformation $a + zb$. This transformation would then give us samples from $N(a,b)$.

What I've described is for the univariate case. You can easily extend this to the multivariate case.

ralph
  • 165
  • 4
  • Thanks , this is helpful for my case , but for that I need to find $ A*A^T=\Sigma$ ,please check the updated question. – Mahajna Dec 20 '20 at 10:41
  • I think you're overthinking this. Recall that $AI = A$, where $I$ is the identity matrix. Given this, what do you think $A$ should be? – ralph Dec 20 '20 at 20:59