# Enforcing independence

Dear,
I wonder how I can exactly enforce independence on two vectors within the same matrix. Imagine matrix f with two columns and 20 rows. Each element in f is a parameter of which I can assume normal distribution. I want to enforce as little covariance between the two columns as possible and preferably each of them to have a variance of one. What would this look like?

\begin{pmatrix} f[,1]\\ f[,2] \end{pmatrix} \sim mvn \begin{pmatrix} 0\\ 0 \end{pmatrix} , \begin{pmatrix} 1 & 0\\ 0 & 1 \end{pmatrix}

// code 1
parameters{
matrix[20, 2] f;
}
transformed parameters{
vector[20] zeros;
matrix[20,20] Sigma;
zeros = rep_vector(0, 20);
Sigma = diag_matrix(rep_vector(1, 20));
}
model{
for(p in 1:2) f[p] ~ multi_norm( zeros,  Sigma);

}


Or alternatively:

// code 2
parameters{
matrix[20, 2] f;
}
transformed parameters{
vector[2] zeros;
matrix[2, 2] Sigma;
zeros = rep_vector(0, 2);
Sigma = diag_matrix( rep_vector(1, 2));
}
model{
for(i in 1:20) f[i] ~ multi_norm( zeros,  Sigma);

}


Should one of these do it? I have been getting some mixed results that make me doubt if I’m coding this correctly.
Thank you!

If you just want to draw a matrix of MxN normal random variables, just use base r:

N = 5
M = 2
matrix(rnorm(M * N), nrow = M, ncol = N)


The posterior is what it is given the model and data. We have very limited control.