How to do repeated random sample from a matrix

5 ビュー (過去 30 日間)
Tommy Tang
Tommy Tang 2016 年 5 月 9 日
コメント済み: Star Strider 2016 年 5 月 9 日
Hi, I am trying to figure out a problem. Suppose I have two matrices,one is parameter matrix B, which is 10,000*11.I obtain B from MVN simulation by 10,000 times. Elements from any row of B is denoted as b0(constant), b1, b2, b3, ...b11. Another matrix is X, an 11*10,000 matrix,The row is the number of observations, and the column is the number of variables. Elements of any column from X is denoted as x1 x2 ...x11.Now I need to randomly select one row from B and one column from X,respectively and then obtain y1= b0+b1*x1+b2*x2+...b11*x11. I need to repeat this process for 10,000 times so that I will obtain a column of 10,000*1 Y(=y1 y2 y3 ...y10,000). Please give me some ideas for this. Thanks!

採用された回答

Star Strider
Star Strider 2016 年 5 月 9 日
編集済み: Star Strider 2016 年 5 月 9 日
It seems to me that you are doing simple matrix multiplication, then summing across the columns:
Y = sum(B*X,2);
  2 件のコメント
Tommy Tang
Tommy Tang 2016 年 5 月 9 日
Yes. I will need to do multiplication. But the difficult part is how to simultaneously select row and column from two matrices and then multiply for 10,000 times.
Star Strider
Star Strider 2016 年 5 月 9 日
The approach I described does all of the multiplications at once. The original product matrix is (10000 x 10000), so to get your (10000 x 1) vector, I add across the columns. I thought that is what you want to do.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by