how to solve a problem about marginal

1 view (last 30 days)
Skydriver
Skydriver on 22 Apr 2019
Commented: Walter Roberson on 15 Sep 2019
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 Comment
Walter Roberson
Walter Roberson on 15 Sep 2019
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.

Sign in to comment.

Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!