# Generating a Matrix of random numbers

So for a Time Series model I need a matrix with random numbers. Lets say we have k = 2 series, and T = 500 numbers of observations for each series. What I want is a matrix with T x k random numbers that differ in each period. In the univariate case this is no problem by simply saying:
eta ~ normal(0,vareta) ; // vareta is a scalar
But if I write
eta ~ multi_normal(rep_row_vector(0,k),vareta) ; // vareta is a covariance matrix
where eta is a T x k matrix I get the error that

No matches for:

matrix ~ multi_normal(row vector, matrix)

Available argument signatures for multi_normal:

vector ~ multi_normal(vector, matrix)
vector ~ multi_normal(row vector, matrix)
row vector ~ multi_normal(vector, matrix)
row vector ~ multi_normal(row vector, matrix)
vector ~ multi_normal(vector[], matrix)
vector ~ multi_normal(row vector[], matrix)
row vector ~ multi_normal(vector[], matrix)
row vector ~ multi_normal(row vector[], matrix)
vector[] ~ multi_normal(vector, matrix)
vector[] ~ multi_normal(row vector, matrix)
row vector[] ~ multi_normal(vector, matrix)
row vector[] ~ multi_normal(row vector, matrix)
vector[] ~ multi_normal(vector[], matrix)
vector[] ~ multi_normal(row vector[], matrix)
row vector[] ~ multi_normal(vector[], matrix)
row vector[] ~ multi_normal(row vector[], matrix)

## require real scalar return type for probability function. error in ‘model18cc231a4b08_MSV23’ at line 58, column 48

``````56:
57: model {
58: eta ~ multi_normal(rep_row_vector(0,k),vareta) ;
^
59:
``````

So i decided to do the following thing:
for (t in 1:T) {
eta[t,] ~ multi_normal(rep_row_vector(0,k),vareta) ;
}
this works and gives me the wanted matrix, but I guess it is very inefficient in terms of sampling speed.

I am gratefull for any hints.

Best
Chris

Use this signature; i.e. declare it as `row_vector[k] eta[T];` rather than a T by k matrix.