MATLAB程序的注释 蒙特卡洛模拟!Randn('seed',0);nuT=(r-0.5*sigma^2)*T;Sit=sigma*sqrt(T);Discpayoff=exp(-r*T)*max(0,s0*exp(nuT+sit*randn(Nu,1))-K);[eucall,varorice,ci}=normfit(discpayoff)Randn('seed',0);nuT=(r-0.5*sigma^2)*T;Sit=sigma*sqrt(T)
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/09 04:53:15
MATLAB程序的注释 蒙特卡洛模拟!Randn('seed',0);nuT=(r-0.5*sigma^2)*T;Sit=sigma*sqrt(T);Discpayoff=exp(-r*T)*max(0,s0*exp(nuT+sit*randn(Nu,1))-K);[eucall,varorice,ci}=normfit(discpayoff)Randn('seed',0);nuT=(r-0.5*sigma^2)*T;Sit=sigma*sqrt(T)
MATLAB程序的注释 蒙特卡洛模拟!
Randn('seed',0);
nuT=(r-0.5*sigma^2)*T;
Sit=sigma*sqrt(T);
Discpayoff=exp(-r*T)*max(0,s0*exp(nuT+sit*randn(Nu,1))-K);
[eucall,varorice,ci}=normfit(discpayoff)
Randn('seed',0);
nuT=(r-0.5*sigma^2)*T;
Sit=sigma*sqrt(T);
Rand=randn(Nu,1);
discpayoff=exp(-r*T)*max(0.s0*exp(nuT+sit*rand)-K);
Discpayoff1=exp(-r*T)*max(0,s0*exp(nuT+sut*-rand)-K);
[eucall,varproce,ci]=normfit([discpayoff;discpayoff1])
Dt=T/NSteps;
Nudt=(r-0.5*sigma^2)*dt;
Sidt=sigma*sqrt(dt);
Randn('seed',0);
Rand=randn(NRep1,NSteps);
Rand1=nudt+sidt*rand;
Rand1=nudt+sidt*rand;
Rand2=cumsum(rand1,2);
Path=s0*exp(rand2);
Payoff=zeros(NRep1,1);
For i=1;Nrep1
Payoff=max(0,mean(path(i,:))-k);
End
[p.aux,CI]=normfit(exp(-r*T)*payoff)
一共三段.老师要求每一行后面都要写上备注,完全不懂啊.
MATLAB程序的注释 蒙特卡洛模拟!Randn('seed',0);nuT=(r-0.5*sigma^2)*T;Sit=sigma*sqrt(T);Discpayoff=exp(-r*T)*max(0,s0*exp(nuT+sit*randn(Nu,1))-K);[eucall,varorice,ci}=normfit(discpayoff)Randn('seed',0);nuT=(r-0.5*sigma^2)*T;Sit=sigma*sqrt(T)
Randn('seed',0);%设定初始随机变量seed为0
nuT=(r-0.5*sigma^2)*T;%计算过程,计算nuT=(r-0.5*sigma^2)*T
Sit=sigma*sqrt(T);%给T开方后乘以sigma等于Sit
Discpayoff=exp(-r*T)*max(0,s0*exp(nuT+sit*randn(Nu,1))-K);%0和s0乘以e的nuT+sit*randn(Nu,1))-K的最大值乘以e的-r*T次方
[eucall,varorice,ci}=normfit(discpayoff)%返回给定数据discapayoff的正太分布参数估计
Randn('seed',0);%设定初始随机变量seed为0
nuT=(r-0.5*sigma^2)*T;%计算过程,计算nuT=(r-0.5*sigma^2)*T
Sit=sigma*sqrt(T);%给T开方后乘以sigma等于Sit
Rand=randn(Nu,1);%产生Nu个随机数,列矩阵
discpayoff=exp(-r*T)*max(0.s0*exp(nuT+sit*rand)-K);%0和s0乘以e的nuT+sit*rand-K的最大值乘以e的-r*T次方
Discpayoff1=exp(-r*T)*max(0,s0*exp(nuT+sut*-rand)-K);%仍然是乘法运算,max的意思是在括号中取他们的最大值
[eucall,varproce,ci]=normfit([discpayoff;discpayoff1])%返回给定数据的正太分布参数估计
%eucall是给定数据的正太分布均值mu,varproce是标准差sigma,95%置信区间
Dt=T/NSteps;%计算Dt
Nudt=(r-0.5*sigma^2)*dt;%%计算过程,计算nuT=(r-0.5*sigma^2)*dt
Sidt=sigma*sqrt(dt);%dt的开方然后乘以sigma
Randn('seed',0);%设定初始随机变量seed为0
Rand=randn(NRep1,NSteps);%产生NSteps列,每列NRep1个随机变量
% Rand1=nudt+sidt*rand;
% Rand1=nudt+sidt*rand;
% Rand2=cumsum(rand1,2);%这三行都是产生随机变量,
Path=s0*exp(rand2);%Path是e的Rand2次方和s0的乘机
Payoff=zeros(NRep1,1);%产生4行1列0矩阵
For i=1;Nrep1%循环,i从1到Nrep1
Payoff=max(0,mean(path(i,:))-k);%payoff的值等于0和path的第i行-k的最大值
End%结束
[p.aux,CI]=normfit(exp(-r*T)*payoff)%返回payoff乘以e的(-r*T)次方的正态分布均值mu和sigma
%P.aux=mu,CI=sigma