how to solve a problem about marginal

1 次查看(过去 30 天)
I have a coding :
h_data = [0; 0.1568; 0.2112; 0.264; 0.3403; 0.469; 0.58; 0.7];
% deltaPGA = h_data(2:8) - h_data(1:7);
Mwgrid = 4.35:0.3:9.15;
amaxgrid = linspace(0,3,36); %0:0.01:3;
grid = meshgrid(Mwgrid,amaxgrid);
PGAgrid = 0.19:0.02:0.39;
for i=1:length(h_data)-1
%calculating Conditional Probability(Mw given PGA>h) in equation (5)
pdfMwPGAh = marginal(:,i);
%calculating Pr(amax,PGA>h) in equation (9)
[PGA_temp,~] = hist(PGA,PGAgrid);
pdfPGA = PGA_temp/sum(PGA_temp);
%calculating joint probability between amax and PGA in equation (9)
%p(amax,PGA)={1/amaxSigln(amax)(2phi)^1/2
%exp[-{ln(amax)-Mln(amax)^2/2Sig^2ln(amax)]Deltaamax}p(PGA)
pdfamaxPGA=zeros(length(amaxgrid),length(PGAgrid));
for j=1:length(amaxgrid)
for k=1:length(pdfPGA)
if PGAgrid(k)>h_data(i+1)
pdfamaxPGA(j,k)=lognpdf(amaxgrid(j),-0.15+(-0.13+1)*log(PGAgrid(k)),0.52).*0.01.*pdfPGA(k);
end
end
end
%Sum Joint Probability between amax and PGA in equation (8)
pdfamaxPGAh = sum(pdfamaxPGA');
%determine conditional probability in equation (7)
if sum(pdfamaxPGAh)~=0
pdfamaxPGAh = pdfamaxPGAh/sum(pdfamaxPGAh);
end
%calculating Pr(amax,Mw,PGA>h) = Pr(amax,PGA>h)*Pr(Mw given
%PGA>h)formulation (5)
for j=1:length(amaxgrid)
for k=1:length(pdfMwPGAh)
pdfamaxMwPGAh(j,k,i)= pdfamaxPGAh(j)*pdfamaxPGAh(j) * pdfMwPGAh(k);
end
end
end
Is there any one can help to solve my problem
Index in position 2 exceeds array bounds (must not exceed 1).
Error in jointpdf_Mw_amax_Juang (line 22)
pdfMwPGAh = marginal(:,i);
  1 个评论
Walter Roberson
Walter Roberson 2019-9-15
You do not show us how you created marginal . As outside observers, we have no reason to expect that it will be any particular size.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assembly 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by