How do I generate all possible weights for a constraint
4 views (last 30 days)
Show older comments
While I was working on my portfolio optimization I wanted to perform a numerical analysis and I wanted to generate several combinations of weights that all sum to 1. in the case of 3 assets I had this code:
for i= 0:0.1:1 for j = 0:0.1:(1-i) w_Consmr = i; w_Manuf = j; w_HiTec = 1-j-i; a = a+1; w(a,:) = [w_Consmr w_Manuf w_HiTec] ; end end
However, now I want to do this for lets say, 50 assets and making 50 for loops seems quite cumbersome, is there another way to make this more efficient ?
Sincerely, Stephan
3 Comments
Matt J
on 11 Apr 2013
Edited: Matt J
on 11 Apr 2013
What do you mean by "several"? For 50 assets, the number of combinations can be intractably large, depending on whether you'd still be using increments of 0.1 or something else. If 0.1, then at most 10 of the weights can be non-zero. Is that what you want?
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Portfolio Optimization and Asset Allocation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!