Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. package technicalmanagement;
  2.  
  3. public class Portfolio {
  4. static final double rm=0.011;
  5. static final double sigmam =0.00262;
  6. static final double sigmaa =0.00036;
  7. static final double sigmab =0.00064;
  8. static final double oujiA = 0.001152768;//王子製紙のα、β
  9. static final double oujiB = 0.71180797;
  10. static final double nitteruA =0.003423932;//新日鉄のα、β
  11. static final double nitteruB =0.144017047;
  12.  
  13. public static void main(String[] args) {
  14. double Mw=0;//投資割合
  15. double MexpectofP=0;//記録用
  16. double MdispersionofP=100;//記録用
  17. for(int i=0;i<1000;i++){
  18. //wを乱数で発生
  19. double expectofP; //期待収益率
  20. double dispersionofP;//分散
  21. double w=Math.random();
  22. expectofP=w*(oujiA+oujiB*rm)+(1-w)*(nitteruA+nitteruB*rm);
  23. dispersionofP=Math.pow((w*oujiB+(1-w)*nitteruB),2)*sigmam+Math.pow(w, 2)*sigmaa+Math.pow((1-w), 2)*sigmab;
  24. if((expectofP>=MexpectofP) && (dispersionofP<=MdispersionofP)){
  25. MexpectofP=expectofP;
  26. MdispersionofP=dispersionofP;
  27. Mw=w;
  28. }
  29. }
  30. System.out.println("期待収益率は"+MexpectofP+",標準偏差は"+Math.sqrt(MdispersionofP));
  31. System.out.println("最適な投資割合は"+Mw+"です。");
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement