欢迎来到天天文库
浏览记录
ID:49116619
大小:336.50 KB
页数:17页
时间:2020-02-28
《随机过程matlab程序.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、%PPT例2一维正态密度与二维正态密度symsxy;s=1;t=2;mu1=0;mu2=0;sigma1=sqrt((1+s^2));sigma2=sqrt((1+t^2));x=-6:0.1:6;f1=1/sqrt(2*pi*sigma1)*exp(-(x-mu1).^2/(2*sigma1^2));f2=1/sqrt(2*pi*sigma2)*exp(-(x-mu2).^2/(2*sigma2^2));plot(x,f1,'r-',x,f2,'k-.')rho=(1+s*t)/(sigma1*sigma2);f=1/(2*pi*sigma1*sigma2*
2、sqrt(1-rho^2))*exp(-1/(2*(1-rho^2))*((x-mu1)^2/sigma1^2-2*rho*(x-mu1)*(y-mu2)/(sigma1*sigma2)+(y-mu2)^2/sigma2^2));ezsurf(f)%%Thedailylogreturnsonthestockhaveameanof0.05/yearandastandarddeviationof0.23/year.Thesecanbeconvertedtoratespertradingdaybydevidingby253andsqrt(253),respectiv
3、ely.Question1:Whatistheprobabilitythatthevalueofthestockwillbebelow$950,000attheclosedayofatleastoneofthenext45tradingdays?clear;niter=1.0E5;%numberofiterationsbelow=repmat(0,1,niter);%setupstoragerandn('seed',0);fori=1:niterr=normrnd(0.05/253,0.23/sqrt(253),1,45);%generaterandomnum
4、berslogPrice=log(1.0E6)+cumsum(r);minlogP=min(logPrice);%minmumpriceovernext45daysbelow(i)=sum(minlogP5、.*cos(w*t+theta);capmu=mean(x)tao=1x1=A.*cos(w*(t+tao)+theta);capgamma=mean((x-capmu).*(x1-capmu))%mtimesimulationclear;w=2;N=1000;mu=2;sigma=3;m=500;capmu1=[];capgamma1=[];fori=1:ms=rand('state');A=mu+sigma*randn(1,N);theta=-pi+2*pi*rand(1,N);t=1:N;x=A.*cos(w*t+theta);capmu=mean(x)6、;capmu1=[capmu1,capmu];tao=1;x1=A.*cos(w*(t+tao)+theta);capgamma=mean((x-capmu).*(x1-capmu));capgamma1=[capgamma1,capgamma];endplot(1:m,capmu1,'*',1:m,capgamma1,'o')capmu=mean(capmu1);capgamma=mean(capgamma1);err1=mean((capmu1-0).^2);gamma=(sigma^2+mu^2)*cos(w*tao)/2;err2=mean((capg7、amma1-gamma).^2);[capmu,capgamma;err1,err2]%输出:0.0058-2.70050.00650.0736%P37例3.1.1p1=poisscdf(5,10)p2=poisspdf(0,10)[p1,p2]%输出p1=0.0671p2=4.5400e-005ans=0.06710.0000%P43例3.2.1p3=poisspdf(9,12)%输出p3=0.0874%P43例3.2.2p4=poisspdf(0,12)%输出p4=6.1442e-006%P39-40(Th3.1.1)Solvethedifferencee8、quationsystem,findt
5、.*cos(w*t+theta);capmu=mean(x)tao=1x1=A.*cos(w*(t+tao)+theta);capgamma=mean((x-capmu).*(x1-capmu))%mtimesimulationclear;w=2;N=1000;mu=2;sigma=3;m=500;capmu1=[];capgamma1=[];fori=1:ms=rand('state');A=mu+sigma*randn(1,N);theta=-pi+2*pi*rand(1,N);t=1:N;x=A.*cos(w*t+theta);capmu=mean(x)
6、;capmu1=[capmu1,capmu];tao=1;x1=A.*cos(w*(t+tao)+theta);capgamma=mean((x-capmu).*(x1-capmu));capgamma1=[capgamma1,capgamma];endplot(1:m,capmu1,'*',1:m,capgamma1,'o')capmu=mean(capmu1);capgamma=mean(capgamma1);err1=mean((capmu1-0).^2);gamma=(sigma^2+mu^2)*cos(w*tao)/2;err2=mean((capg
7、amma1-gamma).^2);[capmu,capgamma;err1,err2]%输出:0.0058-2.70050.00650.0736%P37例3.1.1p1=poisscdf(5,10)p2=poisspdf(0,10)[p1,p2]%输出p1=0.0671p2=4.5400e-005ans=0.06710.0000%P43例3.2.1p3=poisspdf(9,12)%输出p3=0.0874%P43例3.2.2p4=poisspdf(0,12)%输出p4=6.1442e-006%P39-40(Th3.1.1)Solvethedifferencee
8、quationsystem,findt
此文档下载收益归作者所有