i have a problem with my code and i dont know how solve this?

조회 수: 1 (최근 30일)
vachelard
vachelard 2014년 4월 5일
댓글: vachelard 2014년 4월 6일
I have a matrix of monthly returns I call Ynet (193.1) I'd like to build a matrix yields random I call randomR with an average yield of my one line is equal to the value of the row Ynet has.
Ynet example, if (1,1) = 0.23 I need the average randomR (1, :) is equal to 0.23.
Until then I got there, the problem comes from my values of my matrix randomR I need them to be between [-0.25, 0.25] gold mine that is not always the case. Over the size of my matrix randomR must be between 1 and 30 depending on the number of returns I want.
That is where I am:
simulation = -0.2 +0.4 * rand (193.5).;
rowsum = mean (simulation 2);
simulation bsxfun = (@ rdivide, simulation, rowsum);
   for i = 1:5
      randomR (:, i) = simulation (:, i) * Ynet,.
   end
thank you
  댓글 수: 3
vachelard
vachelard 2014년 4월 5일
yes of courses it is writing an error. but even with this i do not get good results
Image Analyst
Image Analyst 2014년 4월 5일
I've read your post 6 times and I can't understand it. Like what does this mean: "I call Ynet (193.1)" What is 193.1? That can't be part of the variable name. We don't know how many more writing errors there might be, so it's best to attach your m-file with the paper clip icon, after you've put in a comment before each line about what that line is supposed to do.

댓글을 달려면 로그인하십시오.

채택된 답변

vachelard
vachelard 2014년 4월 5일
here are the two files my code and my data. I'm sorry, I try to explain the best ... but really thank you for your help In my code the variable a b c d are just to check if my yields often exceed 0.15 because it does not require the ideal is that they are between -0.07 and 0.07 about most of the time
  댓글 수: 2
Image Analyst
Image Analyst 2014년 4월 5일
You forgot to attach rf.xlsx which your code requires.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2014년 4월 5일
mean(simulation, 2)
does not calculate a row sum. You would use sum(simulation, 2) for a row sum
  댓글 수: 2
vachelard
vachelard 2014년 4월 5일
I want the average of the line is equal to the value of my reference matrix. but if it works for the sum I can calculate for the average.
vachelard
vachelard 2014년 4월 5일
My goal if possible is that the numbers in my random matrices does not greatly exceed the maximum and minimum my target matrix

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2014년 4월 5일
Like I said, I can't figure out what you want. You say " I need them (randomR) to be between [-0.25, 0.25] gold mine that is not always the case. Over the size of my matrix randomR must be between 1 and 30". So which is it ? Do you need randomR values to be between -.25 and +.25, OR between 1 and 30?
  댓글 수: 6
vachelard
vachelard 2014년 4월 6일
my goal is to create 3 sizes of random matrices: one with dimensions 193 by 5, where the numbers generated inside are between -0.15 and 0.15. Another one with dimensions 193 by 10, where the numbers generated are also between -0.15 and 0.15. And a third one that is 193 by 15, where the numbers generated are between -0.15 and 0.15. The constraint of these 3 matrixes is that the average, row by row, should be equal to the value of the corresponding row of the first column of the matrix that I called Rhedgefund (which is in the file named data_groupe(noname).) example: if I take the 193x10 matrix, I want the average of line i to be equal to the value of the first column of row i in the matrix Rhedgefund. Thank you
vachelard
vachelard 2014년 4월 6일
if I normalize my yields certainly they will not be totally random but I can distribute it to the desired range or not?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by