⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 insurance.java

📁 金融资产定价,随机过程,MONTE CARLO 模拟 JAVA 程序和文档资料
💻 JAVA
字号:
/* WARANTY NOTICE AND COPYRIGHTThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.Copyright (C) Michael J. Meyermatmjm@mindspring.comspyqqqdia@yahoo.com*//* * Insurance.java * * Created on January 25, 2002, 10:00 PM */ package Examples.Probability;import Processes.*;import Statistics.*;import java.lang.Math.*; /** <p>Console program computing probability of ruin faced by an insurance  * company hit with claims coming in as a compound Poisson process. All  * parameters fixed in source code. No user interaction. See book, chapter 2,  * example 4.</p> * * @author  Michael J. Meyer */public class Insurance{    public static void main(String[] args)    {        String message=        "RUIN OF INSURER:\n\n"+        "An insurance company is hit with claims of size X=N^2, N standard\n"+         "normal( so E(X)=1), with intensity lambda=100 (expected claims per\n"+        "year).\n"+        "Initial claims 0, initial capital 30, premiums: 10% surcharge on\n"+        "expected claims.\n\n"+        "Probability of ruin in 5 years: ";        System.out.print(message);                final int T=50;          // horizon                final double dt=0.1,     // time step                     lambda=100,  // claim intensity                     x_0=0,       // claims at time t=0                     c_0=30;      // initial capital                // event variable (claim size) X=N^2, N standard normal        final RandomVariable X=new RandomVariable(){                    public double getValue(int t)            {                 double z=Random.STN();                 return z*z;             }                          }; // end X;                // premium rate (we know that E(X)=1 but what if X        // were some other random variable)        final double mu=1.1*lambda*X.expectation(20000);                // aggregate claims        final CompoundPoissonProcess         CP=new CompoundPoissonProcess(T,dt,x_0,lambda,X);                // the time of ruin        final StoppingTime tau=new StoppingTime(){                    public boolean stop(int t)            {                 double[] claims=CP.get_path();                 return ((claims[t]>c_0+t*dt*mu)||(t==T));   }                         }; // end tau                // the inidicator function 1_{[tau<T]}        RandomVariable Ruin=new RandomVariable(){            public double getValue(int t)            {                // path computation and value of stopping time                int s=CP.pathSegment(t,tau);                if(s<T) return 1;                return 0;             } // end getValue                        }; // end Ruin                // probability of ruin        double q=Ruin.expectation(20000);        //cut this down to 5 decimals        q=1.0*Math.round(10000*q)/10000;                System.out.print(q);            } // end main    } // end Insurance                                                                                                                                                        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -