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.
vachelard
vachelard 2014 年 4 月 5 日
It's here sorry!

サインインしてコメントする。

その他の回答 (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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by