Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.5K Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Confused about For loop and matrix dimensions

Posted 4 years ago

I am trying to generate a Gaussian random process usign the Karhunen-Loève expansion. I have the eigenvectors and eigenvalues of a Gaussian kernel, a matrix of size 101101 and a vector of length 101. I need to multiply each eigenvector for the root of the eigenvalue and a random Gaussian variable and then add them to obtain a vector of length 101. I have to do this 50 times to generate 50 realizations of the random process. I would like to end with a matrix of size 10150.

I have tried to do this with the following code:

realizationNumber = 50;
evecRand = 0*ConstantArray[1, {longitudeOfEigA}];
evecRand2D = 0*ConstantArray[1, {longitudeOfEigA, realizationNumber}];
realization = 0*ConstantArray[1, {realizationNumber}];

For[i = 0, i < realizationNumber, i++,
 For[j = 0, j < longitudeOfEigA, j++;
  evecRand[[j]] = 
   eval[[j]]^0.5*RandomVariate[NormalDistribution[]]*evec[[j]]; 
  evecRand2D[[j, i]] = 
   evecRand2D[[j, i]] + 
    eval[[j]]^0.5*RandomVariate[NormalDistribution[]]*evec[[j]]]
 ];

This way I think I calculate the evecRand propperly, but I don't know how to add them to calculate each one of the 50 realizations or how to merge all the realizations in a single matrix. Can someone please help me?

Regards. Jaime de la Mota.

POSTED BY: Jaime de la Mota
POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard