Message Boards Message Boards


Confused about For loop and matrix dimensions

Posted 1 month ago
1 Reply
0 Total Likes

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]] = 
  evecRand2D[[j, i]] = 
   evecRand2D[[j, i]] + 

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.

Welcome to Wolfram Community!
Please make sure you know the rules:
Please do NOT post large code and ask to debug it. Minimize your questions to concise code examples pinpointing your issue.

Also this forum is permits only subjects related to Wolfram Technologies. Please remove extra parts of your code and extra files for non-wolfram products such as Maple.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract