1
$\begingroup$

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$.

$\endgroup$
1
2
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ Thanks , this is helpful for my case , but for that I need to find $ A*A^T=\Sigma$ ,please check the updated question. $\endgroup$ – Mahajna Dec 20 '20 at 10:41
  • $\begingroup$ 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? $\endgroup$ – ralph Dec 20 '20 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.