Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package technicalmanagement;
- public class Portfolio {
- static final double rm=0.011;
- static final double sigmam =0.00262;
- static final double sigmaa =0.00036;
- static final double sigmab =0.00064;
- static final double oujiA = 0.001152768;//王子製紙のα、β
- static final double oujiB = 0.71180797;
- static final double nitteruA =0.003423932;//新日鉄のα、β
- static final double nitteruB =0.144017047;
- public static void main(String[] args) {
- double Mw=0;//投資割合
- double MexpectofP=0;//記録用
- double MdispersionofP=100;//記録用
- for(int i=0;i<1000;i++){
- //wを乱数で発生
- double expectofP; //期待収益率
- double dispersionofP;//分散
- double w=Math.random();
- expectofP=w*(oujiA+oujiB*rm)+(1-w)*(nitteruA+nitteruB*rm);
- dispersionofP=Math.pow((w*oujiB+(1-w)*nitteruB),2)*sigmam+Math.pow(w, 2)*sigmaa+Math.pow((1-w), 2)*sigmab;
- if((expectofP>=MexpectofP) && (dispersionofP<=MdispersionofP)){
- MexpectofP=expectofP;
- MdispersionofP=dispersionofP;
- Mw=w;
- }
- }
- System.out.println("期待収益率は"+MexpectofP+",標準偏差は"+Math.sqrt(MdispersionofP));
- System.out.println("最適な投資割合は"+Mw+"です。");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement