0

坚持对这个积分进行数值评估,并且只有做简单正交方案的经验,所以如果这看起来很业余,请多多包涵。下面的嵌套积分使用 Gauss-Hermite(-inf,+inf) 和 Gauss Laguerre 方案的变体 (0,+inf) - 在高斯和 gamma(v/2,2) 密度上。我到了几乎完成积分的地步,中间步骤看起来不错,但我坚持如何组合权重来评估整体积分。对于修改代码/其他想法以编写更好的正交方案来解决问题的建议,我将非常感激。\begin{方程} \int^{\infty} {-\infty}\int^{\infty} {0} \prod_{i=1}^n\Phi \left(\frac{\sqrt{w/v }\,C{i}-a{i}Z}{\sqrt{1a {i^2}}\right)f{z}(Z)f{w}(W)dwdz \end{方程}

% 脚本定义节点、权重、参数然后调用一个主函数和一个子函数

ρ=0.3;nfirms=10;h=repmat(0.1,[1,nfirms]); T=1;R=0.4;v=8;阿尔法=v/2;高斯点=15;

% Quadrature nodes - gaussian and gamma(v/2) from Miranda and Fackler CompEcon
    % toolbox
[x_norm,w_norm] = qnwnorm(GaussPts,0,1);
[x_gamma,w_gamma] = qnwgamma(GaussPts,alpha);
L_mat=zeros(nfirms+1,GaussPts);

for i=1:1:GaussPts;
     L_mat(:,i) = TC_gamma(x_norm(i,:),x_gamma(i,:),h,rho,T,v,nfirms);
end; 

w_norm_mat= repmat(w_norm',nfirms+1,1);
w_gamma_mat = repmat(w_gamma',nfirms+1,1);
% need to weight L_mat by the gaussian and chi-sq i.e, (gamma v/2,2)?
ucl = L_mat.*w_norm;%?? HERE
ucl2 = sum(ucl.*w_gamma2,2);% ?? HERE


function [out] = TC_gamma(x_norm,x_gamma,h,rho,T,v,nfirms)
% calls subfunction feeds into recursion

qki= Vec_CondPTC_gamma(x_norm,x_gamma,h,rho,T,v)' ;

fpdf=zeros(nfirms+1,nfirms+1);
% start at the first point on the tree
 fpdf(1,1)=1; 
    for i=2:nfirms+1 ;
     fpdf(1,i)=fpdf(1,i-1)*(1-qki(:,i-1));
       for j=2:nfirms+1;
       fpdf(j,i)=fpdf(j,i-1)*(1-qki(:,i-1))+fpdf(j-1,i-1)*qki(:,i-1);
     end
   fpdf(i,i)=fpdf(i-1,i-1)*qki(:,i-1);
  end
out=fpdf(:,end);
end% of function TC_gamma


function qki= Vec_CondPTC_gamma(x_norm,x_gamma,h,rho,T,v) 
PD = (1-exp(-kron(h,T)));DB = tinv(PD,v);

a=rho.^0.5; sqrt1_a2 = sqrt(1-sum(a.*a,2));

aM = gtimes(a, x_norm'); Sqrt_W=gamcdf(x_gamma,v/2,2).^0.5;

DB_times_W= gtimes(DB,Sqrt_W); DB_minus_aM = gminus(DB_times_W',aM);

qki=normcdf(grdivide(DB_minus_aM,sqrt1_a2));
end% of function Vec_CondPTC
4

0 回答 0