% Plotting The Given Question With Coordinates
% Plotting The Given Question With Coordinates
% Plotting The Given Question With Coordinates
%SOURCE 1;
range1=s1_long-s1_short;
div1=range1/10;
for i1=0:10;
distance1(i1+1)=s1_short+div1*i1;
end
for j1=1:10;
avg_value(j1)=(distance1(j1)+distance1(j1+1))/2
end
%calculation probabilty;
for i=2:length(distance1)
a(i-1)=sqrt(distance1(i)^2-distance1(1)^2)
end
pa(1)=2*a(1)/110.64;
s1a=s1_long;
s1x=sqrt(s1b^2-s1_short^2);
pa(2)=(a(2)+s1x)/b1;
for i=1:(length(distance1)-3);
pa(i+2)=(a(i+2)+s1x)/b1
end
prob1=[pa(1),diff(pa)];
%SOURCE 2;
range2=s2_long-s2_short;
div2=range2/10;
for i2=0:10;
distance2(i2+1)=s2_short+div2*i2;
end
for j1=1:10;
avg_value2(j1)=(distance2(j1)+distance2(j1+1))/2
end
prob2=count/2500;
prob2=[prob2(1),diff(prob2)];
Distance=distance2(2:11)'
No_of_points_lying_within=count';
No_of_points_lying_between=[count(1),diff(count)]';
for i=1:(length(distance2)-1)
Midpoint_distance(i)=((distance2(i)+distance2(i+1))/2);
end
Midpoint_distance=Midpoint_distance';
Probability=prob2';
Table2=table(Distance,No_of_points_lying_within,No_of_points_lying_betwee
n,Midpoint_distance,Probability)
clear Probablity;
%SOURCE 3;
prob3=1
%barchart
figure(2)
subplot(131);
bar(avg_value,prob1);
xlabel('Distance(km)');
ylabel('P[R=r]');
hold on;
subplot(132);
bar(Midpoint_distance,prob2);
xlabel('Distance(km)');
ylabel('P[R=r]');
hold on;
subplot(133);
bar(60,prob3,10);
axis([0 100 0 2])
xlabel('Distance(km)');
ylabel('P[R=r]');
hold off;
a = axes;
t1 = title('Source to Site probability distribution for source 1,2 and 3');
a.Visible = 'off'; % set(a,'Visible','off');
t1.Visible = 'on'; % set(t1,'Visible','on');
hold off
STEP 2: TEMPORAL UNCERNTAINITY;
lamda_m1=10^(4.4-1*4);
lamda_m2=10^(3.5-0.8*4);
lamda_m3=10^(2.7-1.2*4);
lamda_m=lamda_m1+lamda_m2+lamda_m3;
%source1
mo1=4;
m_max1=7.3;
m_div1=(m_max1-mo1)/10;
for i=0:10;
m_int1(i+1)=mo1+i*m_div1;
end
for i=1:(length(m_int1)-1);
m_avg1(i)=(m_int1(i)+m_int1(i+1))/2
end
for i=1:(length(m_int1)-1)
p_m1(i)=2.303*b(1)*(exp(-2.303*b(1)*(m_avg1(i)-mo1)))/(1-exp(-
2.303*b(1)*(m_max1-mo1)))*(m_int1(i+1)-m_int1(i));
end
Magnitude=m_avg1';
Probability=p_m1';
Table_3=table(Magnitude,Probability)
clear Magnitude Probability
%source2
mo2=4;
m_max2=7.7;
m_div2=(m_max2-mo2)/10;
for i=0:10;
m_int2(i+1)=mo2+i*m_div2;
end
for i=1:(length(m_int2)-1);
m_avg2(i)=(m_int2(i)+m_int2(i+1))/2
end
for i=1:(length(m_int2)-1)
p_m2(i)=2.303*b(2)*(exp(-2.303*b(2)*(m_avg2(i)-mo2)))/(1-exp(-
2.303*b(2)*(m_max2-mo2)))*(m_int2(i+1)-m_int2(i));
end
Magnitude=m_avg2';
Probability=p_m2';
Table_4=table(Magnitude,Probability)
clear Magnitude Probability
%source3
mo3=4;
m_max3=5;
m_div3=(m_max3-mo3)/10;
for i=0:10;
m_int3(i+1)=mo3+i*m_div3;
end
for i=1:(length(m_int3)-1);
m_avg3(i)=(m_int3(i)+m_int3(i+1))/2
end
for i=1:(length(m_int3)-1)
p_m3(i)=2.303*b(3)*(exp(-2.303*b(3)*(m_avg3(i)-mo3)))/(1-exp(-
2.303*b(3)*(m_max3-mo3)))*(m_int3(i+1)-m_int3(i));
end
Magnitude=m_avg3';
Probability=p_m3';
Table_5=table(Magnitude,Probability);
clear Magnitude Probability
%barchart
figure(3)
subplot(131);
bar(m_avg1,p_m1);
xlabel('Magnitude');
ylabel('P[M=m]');
hold on;
subplot(132);
bar(m_avg2,p_m2);
xlabel('Magnitude');
ylabel('P[M=m]');
hold on;
subplot(133);
bar(m_avg3,p_m3);
xlabel('Magnitude');
ylabel('P[M=m]');
hold on;
a2 = axes;
t2 = title('Magnitude probability distribution for source 1,2 and 3');
a2.Visible = 'off'; % set(a,'Visible','off');
t2.Visible = 'on'; % set(t1,'Visible','on');
STEP 4
%SOURCE 1
a_star=0.01:0.01:1;
z=zeros(10,10);
P_m_r1=zeros(10,10);
ln_pha=zeros(10,10);
n=length(a_star);
m=cell(n,1);
l=cell(n,1);
for i=1:n;
for j=1:length(m_avg1);
for k=1:length(avg_value);
ln_pha(j,k)=6.74+0.859*m_avg1(j)-1.80*log(avg_value(k)+25);
end
end
for j=1:length(m_avg1);
for k=1:length(avg_value);
z(j,k)=(log(a_star(i)*981)-ln_pha(j,k))/s_lny;
P_m_r1(j,k)=((1-normcdf(z(j,k)))*p_m1(j)*prob1(k));
end
end
m{i}=(P_m_r1);
l{i}=(P_m_r1*lamda_m1);
end
prob1_final=zeros(1,100);
for i=1:100;
prob1_final(i)=(sum(sum(l{i})));
end
%SOURCE 2
a_star=0.01:0.01:1;
z2=zeros(10,10);
P_m_r2=zeros(10,10);
ln_pha2=zeros(10,10);
n2=length(a_star);
m2=cell(n2,1);
l2=cell(n2,1);
for i=1:n2;
for j=1:length(m_avg2);
for k=1:length(avg_value2);
ln_pha2(j,k)=6.74+0.859*m_avg2(j)-1.80*log(avg_value2(k)+25);
end
end
for j=1:length(m_avg2);
for k=1:length(avg_value2);
z2(j,k)=(log(a_star(i)*981)-ln_pha2(j,k))/s_lny;
P_m_r2(j,k)=((1-normcdf(z2(j,k)))*p_m2(j)*prob2(k));
end
end
m2{i}=(P_m_r2);
l2{i}=(P_m_r2*lamda_m2);
end
prob2_final=zeros(1,100);
for i=1:100;
prob2_final(i)=(sum(sum(l2{i})));
end
%SOURCE 3
a_star=0.01:0.01:1;
z3=zeros(100,10);
P_m_r3=zeros(100,10);
ln_pha3=zeros(100,10);
for i=1:length(a_star);
for j=1:length(m_avg3);
ln_pha3(i,j)=6.74+0.859*m_avg3(j)-1.80*log(s3_dis+25);
z3(i,j)=(log(a_star(i)*981)-ln_pha3(i,j))/s_lny;
P_m_r3(i,j)=((1-normcdf(z3(i,j)))*p_m3(j)*prob3);
end
end
prob3_final=sum(P_m_r3,2)';
p_all=zeros(100,1)
p_all=prob1_final'+prob2_final'+prob3_final';