why 4 varibles together is wrong. whether if seperate varible. in fact , t is sum varible. rest of the varible are integral interval
Not enough input arguments. Error in iyp2. there are 4 varible@(tau,ztau,zpa,t) in the iyP(tau,ztau,zpa,t)but t is independent for sum
4 次查看(过去 30 天)
显示 更早的评论
timerperpeture()
function [Pfin]=timerperpeture(s0,v0,sigma,kappa,K,B) %varibles
s0=100;
v0=0.001;
K=90;
B=0.001;
r=0.01;
sigma=0.15;
kappa=0.1;
rho=0.5;
zpath=(2*sqrt(v0))/sigma;
deta=(4*kappa)/(sigma^2); % Bessel process parameter
nu=deta/2-1; % bessel model index
%syms tau ztau zpa
d=sqrt((1-rho^2)*B);
vaps=@(tau,ztau,zpa)-rho*(2*kappa/(sigma^2)-0.5).*(zpa)+(r*tau)-(B/2)+rho.*(ztau-zpath);
d1=@(tau,ztau,zpa)((log(s0/K)+vaps(tau,ztau,zpa)+(1-rho^2)*B))/d;
d2=@(tau,ztau,zpa)d1-d;
%% laplace inverse
alpha=(9)/(2*B); % laplace parameter,10
f1=@(tau,ztau,zpa,u)((2*sqrt(2*alpha*zpath.*ztau)./(sinh(tau.*sqrt(alpha./2))))./sqrt((pi^3).*zpa).*exp(-(2*sqrt(2*alpha*zpath.*ztau)./(sinh(tau.*sqrt(alpha./2)))).*cosh(u)-(pi^2)./(4.*zpa)-(u.^2)./(4.*zpa)).*sinh(u).*sin(pi.*u./(2.*zpa)));
iy1=@(tau,ztau,zpa)integral(@(u)f1(tau,ztau,zpa,u),0,200*pi,'ArrayValued',1);
iy2=@(tau,ztau,zpa)cell2mat(arrayfun(@(tau,ztau,zpa)iy1(tau,ztau,zpa),tau,ztau,zpa,'UniformOutput',0));
la=@(tau,ztau,zpa)0.5*real(iy2(tau,ztau,zpa).*sqrt(2*alpha).*(ztau.^(nu+1))./(sinh(tau.*sqrt(alpha./2)).*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alpha).*coth(zpa.*sqrt(alpha/2)))));
%la=0.5*real(iy2.*sqrt(2*alpha).*(ztau.^(nu+1))./(sh.*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alpha).*coth(zpa.*sqrt(alpha/2)))));
%% circle
NTR=5;
alphaP=@(t)complex(alpha,(t*pi)/B);
iyfP=@(tau,ztau,zpa,t,u)(2*sqrt(2*alphaP*zpath.*ztau)./sinh(zpa.*sqrt(alphaP/2)))./sqrt(pi^3.*tau).*exp(-(2*sqrt(2*alphaP*zpath.*ztau)./sinh(zpa.*sqrt(alphaP/2))).*cosh(u)-(pi^2-u.^2)./(4.*tau)).*sinh(u).*sin(pi.*u./2.*tau);
iyP=@(tau,ztau,zpa,t)integral(@(u)iyfP(tau,ztau,zpa,t,u),0,200*pi,'ArrayValued',1);
iyp2=@(tau,ztau,zpa,t)cell2mat(arrayfun(@(tau,ztau,zpa,t)iyP(tau,ztau,zpa,t),tau,ztau,zpa,t,'UniformOutput',0));
H2=@(t)@(tau,ztau,zpa)((-1).^(t)).*real(iyp2(tau,ztau,zpa).*sqrt(2*alphaP).*(ztau.^(nu+1))./(sinh(zpa.*sqrt(alphaP/2)).*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alphaP).*coth(zpa.*sqrt(alphaP/2)))));
gH2=H2(2:NTR);
fgH2=@(tau,ztau,zpa)la(tau,ztau,zpa)+sum(gH2(tau,ztau,zpa));
IP=14;
alpha2=@(N)complex(alpha,((NTR+N)*pi)/B);
sh2=@(N)sinh(zpa.*sqrt(alpha2/2));
gP2=@(N)2*sqrt(2*alpha2*zpath.*ztau)./sh2;
iyP2=@(N)@(tau,ztau,zpa)integral(@(u)gP2./sqrt(pi^3.*tau).*exp(-gP.*cosh(u)-(pi^2-u.^2)./(4.*tau)).*sinh(u).*sin(pi.*u./2.*tau),0,200*pi,'ArrayValued',1);
MY=@(N)@(tau,ztau,zpa)(-1)^(NTR+N).*real(iyP2.*sqrt(2*alpha2).*(ztau.^(nu+1))./(sh2.*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alpha2).*coth(zpa.*sqrt(alpha2/2)))));
UMY=MY(1:IP);
C=[1,14,91,364,1001,1848,3003,3432,3003,1848,1001,364,91,14,1];
F=@(tau,ztau,zpa)(fgH2(tau,ztau,zpa)+C(2:IP).*UMY(tau,ztau,zpa));
AVGSU=@(tau,ztau,zpa)(exp(9/2)/B)*sum(F(tau,ztau,zpa))/8192*(s0*exp(vaps-r*tau)*normcdf(d1)-K*exp(-r*tau)*normcdf(d2));
% dx=find(isnan(AVGSU)~=0);
% AVGSU(dx)=0;
% dy=find(isnan(AVGSU1)~=0);
% AVGSU1(dy)=0;
%disthree=@(tau,ztau,zpa,u)(U.*AVGSU)./8192;
Pfin=integral3(@(tau,ztau,zpa)AVGSU(tau,ztau,zpa),0,B,0,1,0,1,'AbsTol', 0,'RelTol',1) %inner expectation
end
回答(1 个)
Walter Roberson
2023-6-20
iyp2=@(tau,ztau,zpa,t)cell2mat(arrayfun(@(tau,ztau,zpa,t)iyP(tau,ztau,zpa,t),tau,ztau,zpa,t,'UniformOutput',0));
iyp2 is defined as expecting four input parameters: tau, ztau, zpa, t
H2=@(t)@(tau,ztau,zpa)((-1).^(t)).*real(iyp2(tau,ztau,zpa).*sqrt(2*alphaP).*(ztau.^(nu+1))./(sinh(zpa.*sqrt(alphaP/2)).*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alphaP).*coth(zpa.*sqrt(alphaP/2)))));
H2 calls iyp2 with only three input parameters: tau, ztau, zpa . It is missing the t value.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Special Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!