update distribution functions for Mmax bias

This commit is contained in:
2020-06-03 08:36:41 +02:00
parent e7412096b1
commit b4e572d7f2
50 changed files with 7680 additions and 7366 deletions

View File

@@ -1,99 +1,99 @@
% [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax) % [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax)
% %
%EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UPPER-BOUNDED G-R %EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UPPER-BOUNDED G-R
% LED MAGNITUDE DISTRIBUTION MODEL. % LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R % Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the % b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the % activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded % stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode. % Gutenberg-Richter estimation mode.
% %
% The exceedance probability of magnitude M' in the time period of % The exceedance probability of magnitude M' in the time period of
% length T' is the probability of an earthquake of magnitude M' or greater % length T' is the probability of an earthquake of magnitude M' or greater
% to occur in T'. Depending on the value of the parameter opt the % to occur in T'. Depending on the value of the parameter opt the
% exceedance probability values are calculated for a fixed time period T' % exceedance probability values are calculated for a fixed time period T'
% and different magnitude values or for a fixed magnitude M' and different % and different magnitude values or for a fixed magnitude M' and different
% time period length values. In either case the independent variable vector % time period length values. In either case the independent variable vector
% starts from xd, up to xu with step dx. In either case the result is % starts from xd, up to xu with step dx. In either case the result is
% returned in the vector z. % returned in the vector z.
% %
%INPUT: %INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0, % y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1 % magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
%OUTPUT: %OUTPUT:
% x - vector of changeable independent variable: magnitudes if opt=0, % x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1, % time period lengths if opt=1,
% x=(xd:dx:xu) % x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x % z - vector of exceedance probability values of the same length as x
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax) function [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end if dx<=0;error('Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
beta=b*log(10); beta=b*log(10);
if opt==0 if opt==0
if xd<Mmin; xd=Mmin;end if xd<Mmin; xd=Mmin;end
if xu>Mmax; xu=Mmax;end if xu>Mmax; xu=Mmax;end
end end
x=(xd:dx:xu)'; x=(xd:dx:xu)';
if opt==0 if opt==0
z=1-exp(-lamb*y.*(1-Cdfgr(x,beta,Mmin-eps/2,Mmax))); z=1-exp(-lamb*y.*(1-Cdfgr(x,beta,Mmin-eps/2,Mmax)));
else else
z=1-exp(-lamb*(1-Cdfgr(y,beta,Mmin-eps/2,Mmax)).*x); z=1-exp(-lamb*(1-Cdfgr(y,beta,Mmin-eps/2,Mmax)).*x);
end end
end end
function [y]=Cdfgr(t,beta,Mmin,Mmax) function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R %CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model % model
% Mmin - catalog completeness level % Mmin - catalog completeness level
% Mmax - upper limit of the distribution % Mmax - upper limit of the distribution
% beta - the distribution parameter % beta - the distribution parameter
% t - vector of magnitudes (independent variable) % t - vector of magnitudes (independent variable)
% y - CDF vector % y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin))); mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian; y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1); idx=find(y>1);
y(idx)=ones(size(idx)); y(idx)=ones(size(idx));
end end

View File

@@ -1,78 +1,78 @@
% [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b) % [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b)
% %
%EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UNLIMITED G-R %EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UNLIMITED G-R
% LED MAGNITUDE DISTRIBUTION MODEL. % LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation % DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution % leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of % from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at % this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the % start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode. % unlimited Gutenberg-Richter estimation mode.
% %
% The exceedance probability of magnitude M' in the time period of % The exceedance probability of magnitude M' in the time period of
% length T' is the probability of an earthquake of magnitude M' or greater % length T' is the probability of an earthquake of magnitude M' or greater
% to occur in T'. Depending on the value of the parameter opt the % to occur in T'. Depending on the value of the parameter opt the
% exceedance probability values are calculated for a fixed time period T' % exceedance probability values are calculated for a fixed time period T'
% and different magnitude values or for a fixed magnitude M' and different % and different magnitude values or for a fixed magnitude M' and different
% time period length values. In either case the independent variable vector % time period length values. In either case the independent variable vector
% starts from xd, up to xu with step dx. In either case the result is % starts from xd, up to xu with step dx. In either case the result is
% returned in the vector z. % returned in the vector z.
% %
%INPUT: %INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0, % y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1 % magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
%OUTPUT %OUTPUT
% x - vector of changeable independent variable: magnitudes if opt=0, % x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1, % time period lengths if opt=1,
% x=(xd:dx:xu) % x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x % z - vector of exceedance probability values of the same length as x
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b) function [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end if dx<=0;error('Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
beta=b*log(10); beta=b*log(10);
if opt==0 if opt==0
if xd<Mmin; xd=Mmin;end if xd<Mmin; xd=Mmin;end
end end
x=(xd:dx:xu)'; x=(xd:dx:xu)';
if opt==0 if opt==0
z=1-exp(-lamb*y.*exp(-beta*(x-Mmin+eps/2))); z=1-exp(-lamb*y.*exp(-beta*(x-Mmin+eps/2)));
else else
z=1-exp(-lamb*exp(-beta*(y-Mmin+eps/2)).*x); z=1-exp(-lamb*exp(-beta*(y-Mmin+eps/2)).*x);
end end
end end

View File

@@ -1,116 +1,116 @@
% [x,z]=ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax) % [x,z]=ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE
% EXCEEDANCE PROBABILITY VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC % EXCEEDANCE PROBABILITY VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE. % DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand % the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters % side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off % namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the % interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of % scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the % magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with % randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2. % respect to the value Mmin-eps/2.
% %
% The exceedance probability of magnitude M' in the time % The exceedance probability of magnitude M' in the time
% period of length T' is the probability of an earthquake of magnitude M' % period of length T' is the probability of an earthquake of magnitude M'
% or greater to occur in T'. % or greater to occur in T'.
% %
% Depending on the value of the parameter opt the exceedance probability % Depending on the value of the parameter opt the exceedance probability
% values are calculated for a fixed time period T' and different magnitude % values are calculated for a fixed time period T' and different magnitude
% values or for a fixed magnitude M' and different time period length % values or for a fixed magnitude M' and different time period length
% values. In either case the independent variable vector starts from % values. In either case the independent variable vector starts from
% xd, up to xu with step dx. In either case the result is returned in the % xd, up to xu with step dx. In either case the result is returned in the
% vector z. % vector z.
% %
% REFERENCES: % REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, % Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 % Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 % Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% x - vector of changeable independent variable x=(xd:dx:xu) % x - vector of changeable independent variable x=(xd:dx:xu)
% z - vector of exceedance probability values % z - vector of exceedance probability values
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [x,z]=... function [x,z]=...
ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax) ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end if dx<=0;error('Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
if opt==0 if opt==0
if xd<Mmin; xd=Mmin;end if xd<Mmin; xd=Mmin;end
if xu>Mmax; xu=Mmax;end if xu>Mmax; xu=Mmax;end
end end
x=(xd:dx:xu)'; x=(xd:dx:xu)';
n=length(x); n=length(x);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
if opt==0 if opt==0
for i=1:n for i=1:n
CDF_NPT=2*(Dystr_npr(x(i),xx,ambd,h)... CDF_NPT=2*(Dystr_npr(x(i),xx,ambd,h)...
-Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian; -Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian;
z(i)=1-exp(-lamb*y.*(1-CDF_NPT)); z(i)=1-exp(-lamb*y.*(1-CDF_NPT));
end end
else else
CDF_NPT=2*(Dystr_npr(y,xx,ambd,h)... CDF_NPT=2*(Dystr_npr(y,xx,ambd,h)...
-Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian; -Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian;
z=1-exp(-lamb*(1-CDF_NPT).*x); z=1-exp(-lamb*(1-CDF_NPT).*x);
if y>Mmax;z=zeros(size(x));end %K15DEC2015 if y>Mmax;z=zeros(size(x));end %K15DEC2015
end end
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,105 +1,105 @@
% [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd) % [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE
% EXCEEDANCE PROBABILITY VALUES FOR THE UNBOUNDED NONPARAMETRIC % EXCEEDANCE PROBABILITY VALUES FOR THE UNBOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE. % DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side. % the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel % The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the % estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample % scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled % - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2. % symmetrically with respect to the value Mmin-eps/2.
% The exceedance probability of magnitude M' in the time period of length % The exceedance probability of magnitude M' in the time period of length
% T' is the probability of an earthquake of magnitude M' or greater to % T' is the probability of an earthquake of magnitude M' or greater to
% occur in T'. % occur in T'.
% Depending on the value of the parameter opt the exceedance probability % Depending on the value of the parameter opt the exceedance probability
% values are calculated for a fixed time period T' and different magnitude % values are calculated for a fixed time period T' and different magnitude
% values or for a fixed magnitude M' and different time period length % values or for a fixed magnitude M' and different time period length
% values. In either case the independent variable vector starts from % values. In either case the independent variable vector starts from
% xd, up to xu with step dx. In either case the result is returned in the % xd, up to xu with step dx. In either case the result is returned in the
% vector z. % vector z.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0, % y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1 % magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
% OUTPUT: % OUTPUT:
% x - vector of changeable independent variable: magnitudes if opt=0, % x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1, % time period lengths if opt=1,
% x=(xd:dx:xu) % x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x % z - vector of exceedance probability values of the same length as x
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd) function [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end if dx<=0;error('Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
x=(xd:dx:xu)'; x=(xd:dx:xu)';
n=length(x); n=length(x);
if opt==0 if opt==0
for i=1:n for i=1:n
CDF_NPU=2*(Dystr_npr(x(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); CDF_NPU=2*(Dystr_npr(x(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
z(i)=1-exp(-lamb*y.*(1-CDF_NPU)); z(i)=1-exp(-lamb*y.*(1-CDF_NPU));
end end
else else
CDF_NPU=2*(Dystr_npr(y,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); CDF_NPU=2*(Dystr_npr(y,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
z=1-exp(-lamb*(1-CDF_NPU).*x); z=1-exp(-lamb*(1-CDF_NPU).*x);
end end
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,59 +1,59 @@
% [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax) % [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax)
%EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UPPER-BOUNDED %EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UPPER-BOUNDED
% G-R LED MAGNITUDE DISTRIBUTION MODEL. % G-R LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R % Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the % b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the % activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded % stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode. % Gutenberg-Richter estimation mode.
% %
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
% INPUT: % INPUT:
% Td - starting period length for maximum credible magnitude calculations % Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations % Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations % dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax) function [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
beta=b*log(10); beta=b*log(10);
mian=(1-exp(-beta*(Mmax-Mmin+eps/2))); mian=(1-exp(-beta*(Mmax-Mmin+eps/2)));
m=Mmin-eps/2-1/beta*log((1-(1-1./(lamb*T))*mian)); m=Mmin-eps/2-1/beta*log((1-(1-1./(lamb*T))*mian));
end end

View File

@@ -1,63 +1,63 @@
% [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b) % [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b)
% %
%EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UNLIMITED %EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UNLIMITED
% G-R LED MAGNITUDE DISTRIBUTION MODEL. % G-R LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation % DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution % leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of % from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at % this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the % start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode. % unlimited Gutenberg-Richter estimation mode.
% %
% The maximum credible magnitude for the period of length T % The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T. % is the magnitude value whose mean return period is T.
% %
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
%INPUT: %INPUT:
% Td - starting period length for maximum credible magnitude calculations % Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations % Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations % dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% %
%OUTPUT: %OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b) function [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
beta=b*log(10); beta=b*log(10);
m=Mmin-eps/2+1/beta.*log(lamb*T); m=Mmin-eps/2+1/beta.*log(lamb*T);
end end

View File

@@ -1,98 +1,98 @@
% [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) % [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM
% CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC % CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE. % DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand % the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters % side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off % namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the % interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of % scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the % magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with % randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2. % respect to the value Mmin-eps/2.
% %
% The maximum credible magnitude for the period of length T % The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T. % is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
% REFERENCES: % REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, % Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 % Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 % Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% Td - starting period length for maximum credible magnitude calculations % Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations % Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations % dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) function [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
n=length(T); n=length(T);
interval=[Mmin-eps/2 Mmax-0.001]; interval=[Mmin-eps/2 Mmax-0.001];
for i=1:n for i=1:n
m(i)=fzero(@F_maxmagn,interval,[],xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i)); m(i)=fzero(@F_maxmagn,interval,[],xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i));
end end
m=m'; m=m';
end end
function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D) function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D)
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h)); mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian; CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian;
y=CDF_NPT-1+1/(lamb*D); y=CDF_NPT-1+1/(lamb*D);
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,98 +1,98 @@
% [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) ---- (Octave Compatible Version) % [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) ---- (Octave Compatible Version)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM
% CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC % CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE. % DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand % the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters % side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off % namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the % interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of % scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the % magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with % randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2. % respect to the value Mmin-eps/2.
% %
% The maximum credible magnitude for the period of length T % The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T. % is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
% REFERENCES: % REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, % Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 % Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 % Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% Td - starting period length for maximum credible magnitude calculations % Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations % Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations % dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) function [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
n=length(T); n=length(T);
interval=[Mmin-eps/2 Mmax-0.001]; interval=[Mmin-eps/2 Mmax-0.001];
for i=1:n for i=1:n
m(i)=fzero(@(t) F_maxmagn(t,xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i)),interval); m(i)=fzero(@(t) F_maxmagn(t,xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i)),interval);
end end
m=m'; m=m';
end end
function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D) function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D)
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h)); mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian; CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian;
y=CDF_NPT-1+1/(lamb*D); y=CDF_NPT-1+1/(lamb*D);
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,98 +1,98 @@
% [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) % [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED % THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE. % NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side. % the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel % The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the % estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample % scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled % - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2. % symmetrically with respect to the value Mmin-eps/2.
% %
% The maximum credible magnitude for the period of length T % The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T. % is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
%INPUT: %INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0, % y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1 % magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
%OUTPUT: %OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) function [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
n=length(T); n=length(T);
interval=[Mmin-eps/2 10.0]; interval=[Mmin-eps/2 10.0];
for i=1:n for i=1:n
m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i)); m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i));
end end
m=m'; m=m';
end end
function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D) function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D)
CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h)); CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
y=CDF_NPU-1+1/(lamb*D); y=CDF_NPU-1+1/(lamb*D);
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,99 +1,99 @@
% [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) ---- (Octave Comlatible Version) % [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) ---- (Octave Comlatible Version)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED % THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE. % NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side. % the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel % The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the % estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample % scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled % - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2. % symmetrically with respect to the value Mmin-eps/2.
% %
% The maximum credible magnitude for the period of length T % The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T. % is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
%INPUT: %INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0, % y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1 % magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
%OUTPUT: %OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) function [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
n=length(T); n=length(T);
interval=[Mmin-eps/2 10.0]; interval=[Mmin-eps/2 10.0];
for i=1:n for i=1:n
% m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i)); % m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i));
m(i)=fzero(@(t) F_maxmagn_NPU(t,xx,h,ambd,Mmin-eps/2,lamb,T(i)),interval); m(i)=fzero(@(t) F_maxmagn_NPU(t,xx,h,ambd,Mmin-eps/2,lamb,T(i)),interval);
end end
m=m'; m=m';
end end
function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D) function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D)
CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h)); CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
y=CDF_NPU-1+1/(lamb*D); y=CDF_NPU-1+1/(lamb*D);
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,259 +1,259 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin) % [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin)
% %
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH % BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS % OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd % THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd
% FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE % FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE
% DISTRIBUTION. % DISTRIBUTION.
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !! % NON-PARAMETRIC HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor % to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian % h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel. % kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the % In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized % kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length - % within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the % eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done % least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0 % assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The % is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole % shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample % data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically % - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing % with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx. % factors row vector for the adaptive kernel is of the same size as xx.
% See: the references below for a more comprehensive description. % See: the references below for a more comprehensive description.
% %
% This is a beta version of the program. Further developments are foreseen. % This is a beta version of the program. Further developments are foreseen.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data) % M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% %
% OUTPUT % OUTPUT
% lamb_all - mean activity rate for all events % lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin % lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is % for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except % continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is % lamb_all and lamb are set to zero and the function execution is
% terminated. % terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of % ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (the zero of the h functional % the optimal smoothing factor has converged (the zero of the h functional
% has been found, ierr=1 when multiple zeros of h functional were % has been found, ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did % encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken. % not zeroe - the approximate h value is taken.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude % xx - the background sample for the nonparametric estimators of magnitude
% distribution % distribution
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=... function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=...
Nonpar(t,M,iop,Mmin) Nonpar(t,M,iop,Mmin)
lamb_err=0; lamb_err=0;
n=length(M); n=length(M);
t1=t(1); t1=t(1);
for i=1:n for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t1=t(i+1); t1=t(i+1);
end end
t2=t(n); t2=t(n);
for i=n:1 for i=n:1
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t2=t(i-1);
end end
nn=0; nn=0;
for i=1:n for i=1:n
if M(i)>=Mmin if M(i)>=Mmin
nn=nn+1; nn=nn+1;
end end
end end
if iop==0 if iop==0
lamb_all=n/round(t(n)-t(1)); lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1); lamb=nn/round(t2-t1);
unit='day'; unit='day';
elseif iop==1 elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014 lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014 lamb=30*nn/(t2-t1); % K20OCT2014
unit='month'; unit='month';
else else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014 lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014 lamb=365*nn/(t2-t1); % K20OCT2014
unit='year'; unit='year';
end end
if nn<50 if nn<50
eps=0;ierr=0;h=0; eps=0;ierr=0;h=0;
lamb_err=1; lamb_err=1;
return; return;
end end
eps=magn_accur(M); eps=magn_accur(M);
n=0; n=0;
for i=1:length(M) for i=1:length(M)
if M(i)>=Mmin; if M(i)>=Mmin;
n=n+1; n=n+1;
x(n)=M(i); x(n)=M(i);
end end
end end
x=sort(x)'; x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2); beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta); [xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx); xx=sort(xx);
clear x; clear x;
xx = podwajanie(xx,Mmin-eps/2); xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx); [h,ierr]=hopt(xx);
[ambd]=scaling(xx,h); [ambd]=scaling(xx,h);
end end
function [m_corr]=korekta(m,Mmin,eps,beta) function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL % RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
% %
% m - input vector of magnitudes % m - input vector of magnitudes
% Mmin - catalog completeness level % Mmin - catalog completeness level
% eps - accuracy of magnitude % eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution % beta - the parameter of the unbounded exponential distribution
% %
% m_corr - vector of randomized magnitudes % m_corr - vector of randomized magnitudes
% %
F1=1-exp(-beta*(m-Mmin-0.5*eps)); F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps)); F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m)); u=rand(size(m));
w=u.*(F2-F1)+F1; w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta; m_corr=Mmin-log(1-w)./beta;
end end
function x2 = podwajanie(x,x0) function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE % DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs % If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and % to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0] % belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)] % then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector % x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending % x2 - is the column vector of data doubled and sorted in the ascending
% order % order
x2=[-x+2*x0 x2=[-x+2*x0
x]; x];
x2=sort(x2); x2=sort(x2);
end end
function [h,ierr]=hopt(x) function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares %Estimation of the optimal smoothing factor by means of the least squares
%method %method
% x - column data vector % x - column data vector
% The result is an optimal smoothing factor % The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used % ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct' % The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros % NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search % search
% MODIFIED JUNE 2014 % MODIFIED JUNE 2014
ierr=0; ierr=0;
n=length(x); n=length(x);
x=sort(x); x=sort(x);
interval=[0.000001 2*std(x)/n^0.2]; interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
[hh(1),fval,exitflag]=fzero(@funct,interval,[],x); [hh(1),fval,exitflag]=fzero(@funct,interval,[],x);
% Extra zeros search % Extra zeros search
jj=1; jj=1;
for kk=2:7 for kk=2:7
interval(1)=1.1*hh(jj); interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj); interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
jj=jj+1; jj=jj+1;
[hh(jj),fval,exitflag]=fzero(@funct,interval,[],x); [hh(jj),fval,exitflag]=fzero(@funct,interval,[],x);
end end
end end
if jj>1;ierr=1;end if jj>1;ierr=1;end
h=max(hh); h=max(hh);
if exitflag==1;return;end if exitflag==1;return;end
end end
h=0.891836*(mean(x)-x(1))/(n^0.2); h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2; ierr=2;
end end
function [fct]=funct(t,x) function [fct]=funct(t,x)
p2=1.41421356; p2=1.41421356;
n=length(x); n=length(x);
yy=zeros(size(x)); yy=zeros(size(x));
for i=1:n, for i=1:n,
xij=(x-x(i)).^2/t^2; xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1); y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y); yy(i)=sum(y);
end; end;
fct=sum(yy)-2*n; fct=sum(yy)-2*n;
clear xij y yy; clear xij y yy;
end end
function [ambd]=scaling(x,h) function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE % EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION % ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending % x - the n dimensional column vector of data values sorted in the ascending
% order % order
% h - the optimal smoothing factor % h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors % ambd - the resultant n dimensional row vector of local scaling factors
n=length(x); n=length(x);
c=sqrt(2*pi); c=sqrt(2*pi);
gau=zeros(1,n); gau=zeros(1,n);
for i=1:n, for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h; gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end end
g=exp(mean(log(gau))); g=exp(mean(log(gau)));
ambd=sqrt(g./gau); ambd=sqrt(g./gau);
end end
function [eps]=magn_accur(M) function [eps]=magn_accur(M)
x=sort(M); x=sort(M);
d=x(2:length(x))-x(1:length(x)-1); d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); eps=min(d(d>0));
if eps>0.1; eps=0.1;end if eps>0.1; eps=0.1;end
end end

View File

@@ -1,310 +1,310 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin) % [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin)
% %
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH % BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS % OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd % THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd
% FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE % FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE
% DISTRIBUTION. % DISTRIBUTION.
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !! % NON-PARAMETRIC HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project. % AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor % to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian % h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel. % kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the % In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized % kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length - % within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the % eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done % least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0 % assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The % is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole % shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample % data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically % - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing % with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx. % factors row vector for the adaptive kernel is of the same size as xx.
% See: the references below for a more comprehensive description. % See: the references below for a more comprehensive description.
% %
% This is a beta version of the program. Further developments are foreseen. % This is a beta version of the program. Further developments are foreseen.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data) % M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% %
% OUTPUT % OUTPUT
% lamb_all - mean activity rate for all events % lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin % lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is % for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except % continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is % lamb_all and lamb are set to zero and the function execution is
% terminated. % terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of % ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (the zero of the h functional % the optimal smoothing factor has converged (the zero of the h functional
% has been found, ierr=1 when multiple zeros of h functional were % has been found, ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did % encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken. % not zeroe - the approximate h value is taken.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude % xx - the background sample for the nonparametric estimators of magnitude
% distribution % distribution
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=... function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=...
Nonpar_O(t,M,iop,Mmin) Nonpar_O(t,M,iop,Mmin)
if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP t=[1 2];M=[1 2]; end %K30SEP
lamb_err=0; lamb_err=0;
%%% %%%%%%%%%%%%%MICHAL %%% %%%%%%%%%%%%%MICHAL
xx=NaN; xx=NaN;
ambd=NaN; ambd=NaN;
%%% %%%%%%%%%%%%%MICHAL %%% %%%%%%%%%%%%%MICHAL
n=length(M); n=length(M);
t1=t(1); t1=t(1);
for i=1:n for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t1=t(i+1); t1=t(i+1);
end end
t2=t(n); t2=t(n);
for i=n:1 for i=n:1
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t2=t(i-1);
end end
nn=0; nn=0;
for i=1:n for i=1:n
if M(i)>=Mmin if M(i)>=Mmin
nn=nn+1; nn=nn+1;
end end
end end
% SL 03MAR2015 ---------------------------------- % SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop); [NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM; lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop); [NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM; lamb=nn/NM;
% SL 03MAR2015 ---------------------------------- % SL 03MAR2015 ----------------------------------
if nn<50 if nn<50
eps=0;ierr=0;h=0; eps=0;ierr=0;h=0;
lamb_err=1; lamb_err=1;
return; return;
end end
eps=magn_accur(M); eps=magn_accur(M);
n=0; n=0;
for i=1:length(M) for i=1:length(M)
if M(i)>=Mmin; if M(i)>=Mmin;
n=n+1; n=n+1;
x(n)=M(i); x(n)=M(i);
end end
end end
x=sort(x)'; x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2); beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta); [xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx); xx=sort(xx);
clear x; clear x;
xx = podwajanie(xx,Mmin-eps/2); xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx); [h,ierr]=hopt(xx);
[ambd]=scaling(xx,h); [ambd]=scaling(xx,h);
% enai=dlmread('para.txt'); %for fixed xx,ambd to test in different platforms % enai=dlmread('para.txt'); %for fixed xx,ambd to test in different platforms
% [ambd]=enai(:,1); % [ambd]=enai(:,1);
% xx=enai(:,2)'; % xx=enai(:,2)';
% [h,ierr]=hopt(xx); % [h,ierr]=hopt(xx);
end end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT % TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
% %
% t1 - start time (in MATLAB numerical format) % t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1 % t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% %
% NM - number of time units from t1 to t2 % NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0 if iop==0
NM=(t2-t1); NM=(t2-t1);
unit='day'; unit='day';
elseif iop==1 elseif iop==1
V1=datevec(t1); V1=datevec(t1);
V2=datevec(t2); V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))... NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12; +(V2(1)-V1(1)-1)*12;
unit='month'; unit='month';
else else
V1=datevec(t1); V1=datevec(t1);
V2=datevec(t2); V2=datevec(t2);
NM2=V2(3); NM2=V2(3);
if V2(2)>1 if V2(2)>1
for k=1:V2(2)-1 for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k); NM2=NM2+eomday(V2(1),k);
end end
end end
day2=365; if eomday(V2(1),2)==29; day2=366; end; day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2; NM2=NM2/day2;
NM1=V1(3); NM1=V1(3);
if V1(2)>1 if V1(2)>1
for k=1:V1(2)-1 for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k); NM1=NM1+eomday(V1(1),k);
end end
end end
day1=365; if eomday(V1(1),2)==29; day1=366; end; day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1; NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1; NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year'; unit='year';
end end
end end
function [m_corr]=korekta(m,Mmin,eps,beta) function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL % RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
% %
% m - input vector of magnitudes % m - input vector of magnitudes
% Mmin - catalog completeness level % Mmin - catalog completeness level
% eps - accuracy of magnitude % eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution % beta - the parameter of the unbounded exponential distribution
% %
% m_corr - vector of randomized magnitudes % m_corr - vector of randomized magnitudes
% %
F1=1-exp(-beta*(m-Mmin-0.5*eps)); F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps)); F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m)); u=rand(size(m));
w=u.*(F2-F1)+F1; w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta; m_corr=Mmin-log(1-w)./beta;
end end
function x2 = podwajanie(x,x0) function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE % DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs % If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and % to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0] % belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)] % then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector % x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending % x2 - is the column vector of data doubled and sorted in the ascending
% order % order
x2=[-x+2*x0 x2=[-x+2*x0
x]; x];
x2=sort(x2); x2=sort(x2);
end end
function [h,ierr]=hopt(x) function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares %Estimation of the optimal smoothing factor by means of the least squares
%method %method
% x - column data vector % x - column data vector
% The result is an optimal smoothing factor % The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used % ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct' % The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros % NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search % search
% MODIFIED JUNE 2014 % MODIFIED JUNE 2014
ierr=0; ierr=0;
n=length(x); n=length(x);
x=sort(x); x=sort(x);
interval=[0.000001 2*std(x)/n^0.2]; interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
fun = @(t) funct(t,x); % FOR OCTAVE fun = @(t) funct(t,x); % FOR OCTAVE
x0 =interval; % FOR OCTAVE x0 =interval; % FOR OCTAVE
[hh(1),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE [hh(1),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE
% Extra zeros search % Extra zeros search
jj=1; jj=1;
for kk=2:7 for kk=2:7
interval(1)=1.1*hh(jj); interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj); interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
jj=jj+1; jj=jj+1;
fun = @(t) funct(t,x); % FOR OCTAVE fun = @(t) funct(t,x); % FOR OCTAVE
x0 =interval; % FOR OCTAVE x0 =interval; % FOR OCTAVE
[hh(jj),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE [hh(jj),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE
end end
end end
if jj>1;ierr=1;end if jj>1;ierr=1;end
h=max(hh); h=max(hh);
if exitflag==1;return;end if exitflag==1;return;end
end end
h=0.891836*(mean(x)-x(1))/(n^0.2); h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2; ierr=2;
end end
function [fct]=funct(t,x) function [fct]=funct(t,x)
p2=1.41421356; p2=1.41421356;
n=length(x); n=length(x);
yy=zeros(size(x)); yy=zeros(size(x));
for i=1:n, for i=1:n,
xij=(x-x(i)).^2/t^2; xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1); y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y); yy(i)=sum(y);
end; end;
fct=sum(yy)-2*n; fct=sum(yy)-2*n;
clear xij y yy; clear xij y yy;
end end
function [ambd]=scaling(x,h) function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE % EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION % ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending % x - the n dimensional column vector of data values sorted in the ascending
% order % order
% h - the optimal smoothing factor % h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors % ambd - the resultant n dimensional row vector of local scaling factors
n=length(x); n=length(x);
c=sqrt(2*pi); c=sqrt(2*pi);
gau=zeros(1,n); gau=zeros(1,n);
for i=1:n, for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h; gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end end
g=exp(mean(log(gau))); g=exp(mean(log(gau)));
ambd=sqrt(g./gau); ambd=sqrt(g./gau);
end end
function [eps]=magn_accur(M) function [eps]=magn_accur(M)
x=sort(M); x=sort(M);
d=x(2:length(x))-x(1:length(x)-1); d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); eps=min(d(d>0));
if eps>0.1; eps=0.1;end if eps>0.1; eps=0.1;end
end end

View File

@@ -1,373 +1,373 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]= % [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=
% Nonpar(t,M,iop,Mmin) % Nonpar(t,M,iop,Mmin)
% %
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH % BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS % OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND % THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND
% THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC % THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC
% ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE % ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE
% ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION. % ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION.
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !! % NON-PARAMETRIC HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor % to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian % h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel. % kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the % In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized % kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length - % within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the % eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done % least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0 % assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The % is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole % shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample % data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically % - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing % with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx. % factors row vector for the adaptive kernel is of the same size as xx.
% The mean activity rate, lamb, is the number of events >=Mmin into the % The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. % length of the period in which they occurred.
% The upper limit of the distribution Mmax is evaluated using % The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the % the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used: % Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)). % Mmaxest= 2(max obs M) - (second max obs M)).
% %
% See: the references below for a more comprehensive description. % See: the references below for a more comprehensive description.
% %
% This is a beta version of the program. Further developments are foreseen. % This is a beta version of the program. Further developments are foreseen.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654 %Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673, %Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y % doi: 10.2478/s11600-010-0049-y
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data) % M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% %
% OUTPUT % OUTPUT
% lamb_all - mean activity rate for all events % lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin % lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is % for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except % continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is % lamb_all and lamb are set to zero and the function execution is
% terminated. % terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of % ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (a zero of the h functional % the optimal smoothing factor has converged (a zero of the h functional
% has been found), ierr=1 when multiple zeros of h functional were % has been found), ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did % encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken. % not zeroe - the approximate h value is taken.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude % xx - the background sample for the nonparametric estimators of magnitude
% distribution % distribution
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 - % err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock % no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used. % method used.
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=... function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=...
Nonpar_tr(t,M,iop,Mmin) Nonpar_tr(t,M,iop,Mmin)
lamb_err=0; lamb_err=0;
n=length(M); n=length(M);
t1=t(1); t1=t(1);
for i=1:n for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t1=t(i+1); t1=t(i+1);
end end
t2=t(n); t2=t(n);
for i=n:1 for i=n:1
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t2=t(i-1);
end end
nn=0; nn=0;
for i=1:n for i=1:n
if M(i)>=Mmin if M(i)>=Mmin
nn=nn+1; nn=nn+1;
end end
end end
if iop==0 if iop==0
lamb_all=n/round(t(n)-t(1)); lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1); lamb=nn/round(t2-t1);
unit='day'; unit='day';
elseif iop==1 elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014 lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014 lamb=30*nn/(t2-t1); % K20OCT2014
unit='month'; unit='month';
else else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014 lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014 lamb=365*nn/(t2-t1); % K20OCT2014
unit='year'; unit='year';
end end
if nn<50 if nn<50
eps=0;ierr=0;h=0;Mmax=0;err=0; eps=0;ierr=0;h=0;Mmax=0;err=0;
lamb_err=1; lamb_err=1;
return; return;
end end
eps=magn_accur(M); eps=magn_accur(M);
n=0; n=0;
for i=1:length(M) for i=1:length(M)
if M(i)>=Mmin; if M(i)>=Mmin;
n=n+1; n=n+1;
x(n)=M(i); x(n)=M(i);
end end
end end
x=sort(x)'; x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2); beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta); [xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx); xx=sort(xx);
clear x; clear x;
xx = podwajanie(xx,Mmin-eps/2); xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx); [h,ierr]=hopt(xx);
[ambd]=scaling(xx,h); [ambd]=scaling(xx,h);
[Mmax,err]=Mmaxest(xx,h,Mmin-eps/2); [Mmax,err]=Mmaxest(xx,h,Mmin-eps/2);
end end
function [m_corr]=korekta(m,Mmin,eps,beta) function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL % RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
% %
% m - input vector of magnitudes % m - input vector of magnitudes
% Mmin - catalog completeness level % Mmin - catalog completeness level
% eps - accuracy of magnitude % eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution % beta - the parameter of the unbounded exponential distribution
% %
% m_corr - vector of randomized magnitudes % m_corr - vector of randomized magnitudes
% %
F1=1-exp(-beta*(m-Mmin-0.5*eps)); F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps)); F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m)); u=rand(size(m));
w=u.*(F2-F1)+F1; w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta; m_corr=Mmin-log(1-w)./beta;
end end
function x2 = podwajanie(x,x0) function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE % DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs % If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and % to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0] % belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)] % then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector % x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending % x2 - is the column vector of data doubled and sorted in the ascending
% order % order
x2=[-x+2*x0 x2=[-x+2*x0
x]; x];
x2=sort(x2); x2=sort(x2);
end end
function [h,ierr]=hopt(x) function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares %Estimation of the optimal smoothing factor by means of the least squares
%method %method
% x - column data vector % x - column data vector
% The result is an optimal smoothing factor % The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used % ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct' % The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros % NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search % search
% MODIFIED JUNE 2014 % MODIFIED JUNE 2014
ierr=0; ierr=0;
n=length(x); n=length(x);
x=sort(x); x=sort(x);
interval=[0.000001 2*std(x)/n^0.2]; interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
[hh(1),fval,exitflag]=fzero(@funct,interval,[],x); [hh(1),fval,exitflag]=fzero(@funct,interval,[],x);
% Extra zeros search % Extra zeros search
jj=1; jj=1;
for kk=2:7 for kk=2:7
interval(1)=1.1*hh(jj); interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj); interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
jj=jj+1; jj=jj+1;
[hh(jj),fval,exitflag]=fzero(@funct,interval,[],x); [hh(jj),fval,exitflag]=fzero(@funct,interval,[],x);
end end
end end
if jj>1;ierr=1;end if jj>1;ierr=1;end
h=max(hh); h=max(hh);
if exitflag==1;return;end if exitflag==1;return;end
end end
h=0.891836*(mean(x)-x(1))/(n^0.2); h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2; ierr=2;
end end
function [fct]=funct(t,x) function [fct]=funct(t,x)
p2=1.41421356; p2=1.41421356;
n=length(x); n=length(x);
yy=zeros(size(x)); yy=zeros(size(x));
for i=1:n, for i=1:n,
xij=(x-x(i)).^2/t^2; xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1); y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y); yy(i)=sum(y);
end; end;
fct=sum(yy)-2*n; fct=sum(yy)-2*n;
clear xij y yy; clear xij y yy;
end end
function [ambd]=scaling(x,h) function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE % EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION % ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending % x - the n dimensional column vector of data values sorted in the ascending
% order % order
% h - the optimal smoothing factor % h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors % ambd - the resultant n dimensional row vector of local scaling factors
n=length(x); n=length(x);
c=sqrt(2*pi); c=sqrt(2*pi);
gau=zeros(1,n); gau=zeros(1,n);
for i=1:n, for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h; gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end end
g=exp(mean(log(gau))); g=exp(mean(log(gau)));
ambd=sqrt(g./gau); ambd=sqrt(g./gau);
end end
function [eps]=magn_accur(M) function [eps]=magn_accur(M)
x=sort(M); x=sort(M);
d=x(2:length(x))-x(1:length(x)-1); d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); eps=min(d(d>0));
if eps>0.1; eps=0.1;end if eps>0.1; eps=0.1;end
end end
function [Mmax,ierr]=Mmaxest(x,h,Mmin) function [Mmax,ierr]=Mmaxest(x,h,Mmin)
% ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS % ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS
% x - row vector of magnitudes (basic sample). % x - row vector of magnitudes (basic sample).
% h - optimal smoothing factor % h - optimal smoothing factor
% Mmax - upper bound % Mmax - upper bound
% ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas % ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas
% estimation % estimation
% Uses function 'dystryb' % Uses function 'dystryb'
n=length(x); n=length(x);
ierr=1; ierr=1;
x=sort(x); x=sort(x);
Mmax1=x(n); Mmax1=x(n);
for i=1:50, for i=1:50,
d=normcdf((Mmin-x)./h); d=normcdf((Mmin-x)./h);
mian=sum(normcdf((Mmax1-x)./h)-d); mian=sum(normcdf((Mmax1-x)./h)-d);
Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d); Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d);
if abs(Mmax-Mmax1)<0.01 if abs(Mmax-Mmax1)<0.01
ierr=0;break; ierr=0;break;
end end
Mmax1=Mmax; Mmax1=Mmax;
end end
if (ierr==1 || Mmax>9) if (ierr==1 || Mmax>9)
Mmax=2*x(n)-x(n-1); Mmax=2*x(n)-x(n-1);
ierr=1; ierr=1;
end end
end end
function [y]=dystryb(z,h,mian,x,d) function [y]=dystryb(z,h,mian,x,d)
n=length(x); n=length(x);
m=length(z); m=length(z);
for i=1:m, for i=1:m,
t=(z(i)-x)./h; t=(z(i)-x)./h;
t=normcdf(t); t=normcdf(t);
yy=sum(t-d); yy=sum(t-d);
y(i)=(yy/mian)^n; y(i)=(yy/mian)^n;
end end
end end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin) function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY % Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated % funfc - string with the name of function to be integrated
% a,b - integration limits % a,b - integration limits
% eps - accurracy % eps - accurracy
% varargin - other parameters of function to be integrated % varargin - other parameters of function to be integrated
% calka - integral % calka - integral
% ier=0 - convergence, ier=1 - no conbergence % ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ... W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ... 0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ... 0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069]; 0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ... X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ... 0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ... 0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637]; 0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12; CONST=1E-12;
delta=CONST*abs(a-b); delta=CONST*abs(a-b);
calka=0.; calka=0.;
aa=a; aa=a;
y=b-aa; y=b-aa;
ier=0; ier=0;
while abs(y)>delta, while abs(y)>delta,
bb=aa+y; bb=aa+y;
c1=0.5*(aa+bb); c1=0.5*(aa+bb);
c2=c1-aa; c2=c1-aa;
s8=0.; s8=0.;
s16=0.; s16=0.;
for i=1:4, for i=1:4,
u=X(i)*c2; u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end end
for i=5:12, for i=5:12,
u=X(i)*c2; u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end end
s8=s8*c2; s8=s8*c2;
s16=s16*c2; s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16)) if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y; y=0.5*y;
calka=0.; calka=0.;
ier=1; ier=1;
else else
calka=calka+s16; calka=calka+s16;
aa=bb; aa=bb;
y=b-aa; y=b-aa;
ier=0; ier=0;
end end
end end
end end

View File

@@ -1,431 +1,506 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]= % [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err,BIAS,SD]=
% Nonpar_tr(t,M,iop,Mmin) % Nonpar_tr(t,M,iop,Mmin,Mmax,Nsynth)
% %
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH % BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS % OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND % THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND
% THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC % THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC
% ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE % ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE
% ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION. % ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION.
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !! % NON-PARAMETRIC HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project. % AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor % to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian % h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel. % kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the % In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized % kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length - % within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the % eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done % least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0 % assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The % is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole % shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample % data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically % - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing % with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx. % factors row vector for the adaptive kernel is of the same size as xx.
% The mean activity rate, lamb, is the number of events >=Mmin into the % The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. % length of the period in which they occurred.
% The upper limit of the distribution Mmax is evaluated using % The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the % the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used: % Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)). % Mmaxest= 2(max obs M) - (second max obs M)).
% %
% See: the references below for a more comprehensive description. % See: the references below for a more comprehensive description.
% %
% This is a beta version of the program. Further developments are foreseen. % This is a beta version of the program. Further developments are foreseen.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654 %Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673, %Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y % doi: 10.2478/s11600-010-0049-y
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data) % M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% % Mmax - upper limit of Magnitude Distribution. Can be set by user, or
% OUTPUT % estimate within the program - it then should be set as Mmax=[].
% lamb_all - mean activity rate for all events %
% lamb - mean activity rate for events >= Mmin % OUTPUT
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_all - mean activity rate for all events
% for 50 or more events >=Mmin and the parameter estimation is % lamb - mean activity rate for events >= Mmin
% continued, lamb_err=1 otherwise, all output paramters except % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% lamb_all and lamb are set to zero and the function execution is % for 50 or more events >=Mmin and the parameter estimation is
% terminated. % continued, lamb_err=1 otherwise, all output paramters except
% unit - string with name of time unit used ('year' or 'month' or 'day'). % lamb_all and lamb are set to zero and the function execution is
% eps - length of round-off interval of magnitudes. % terminated.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of % unit - string with name of time unit used ('year' or 'month' or 'day').
% the optimal smoothing factor has converged (a zero of the h functional % eps - length of round-off interval of magnitudes.
% has been found), ierr=1 when multiple zeros of h functional were % ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% encountered - the largest h is accepted, ierr = 2 when h functional did % the optimal smoothing factor has converged (a zero of the h functional
% not zeroe - the approximate h value is taken. % has been found), ierr=1 when multiple zeros of h functional were
% h - kernel smoothing factor. % encountered - the largest h is accepted, ierr = 2 when h functional did
% xx - the background sample for the nonparametric estimators of magnitude % not zeroe - the approximate h value is taken.
% distribution % h - kernel smoothing factor.
% ambd - the weigthing factors for the adaptive kernel % xx - the background sample for the nonparametric estimators of magnitude
% Mmax - upper limit of magnitude distribution % distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 - % ambd - the weigthing factors for the adaptive kernel
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock % Mmax - upper limit of magnitude distribution
% method used. % err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% % no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% LICENSE % method used.
% This file is a part of the IS-EPOS e-PLATFORM. % BIAS - Mmax estimation Bias (Lasocki and Urban, 2011)
% % SD - Mmax standard deviation (Lasocki ands Urban, 2011)
% This is free software: you can redistribute it and/or modify it under %
% the terms of the GNU General Public License as published by the Free % LICENSE
% Software Foundation, either version 3 of the License, or % This file is a part of the IS-EPOS e-PLATFORM.
% (at your option) any later version. %
% % This is free software: you can redistribute it and/or modify it under
% This program is distributed in the hope that it will be useful, % the terms of the GNU General Public License as published by the Free
% but WITHOUT ANY WARRANTY; without even the implied warranty of % Software Foundation, either version 3 of the License, or
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % (at your option) any later version.
% GNU General Public License for more details. %
% % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=... % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Nonpar_tr_O(t,M,iop,Mmin,Mmax) % GNU General Public License for more details.
%
if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err,BIAS,SD]=...
Nonpar_tr_Ob(t,M,iop,Mmin,Mmax,Nsynth)
lamb_err=0; if nargin==5;Nsynth=[];end % K08DEC2019
n=length(M); if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT
t1=t(1); t=[1 2];M=[1 2]; end %K30SEP
%%% %%%%%%%%%%%%%MICHAL
xx=NaN; lamb_err=0;
ambd=NaN; n=length(M);
%%% %%%%%%%%%%%%%MICHAL t1=t(1);
for i=1:n %%% %%%%%%%%%%%%%MICHAL
if M(i)>=Mmin; break; end xx=NaN;
t1=t(i+1); ambd=NaN;
end %%% %%%%%%%%%%%%%MICHAL
t2=t(n); for i=1:n
for i=n:1 if M(i)>=Mmin; break; end
if M(i)>=Mmin; break; end t1=t(i+1);
t2=t(i-1); end
end t2=t(n);
nn=0; for i=n:1
for i=1:n if M(i)>=Mmin; break; end
if M(i)>=Mmin t2=t(i-1);
nn=nn+1; end
end nn=0;
end for i=1:n
% SL 03MAR2015 ---------------------------------- if M(i)>=Mmin
[NM,unit]=time_diff(t(1),t(n),iop); nn=nn+1;
lamb_all=n/NM; end
[NM,unit]=time_diff(t1,t2,iop); end
lamb=nn/NM; % SL 03MAR2015 ----------------------------------
% SL 03MAR2015 ---------------------------------- [NM,unit]=time_diff(t(1),t(n),iop);
if nn<50 lamb_all=n/NM;
eps=0;ierr=0;h=0;Mmax=0;err=0; [NM,unit]=time_diff(t1,t2,iop);
lamb_err=1; lamb=nn/NM;
return; % SL 03MAR2015 ----------------------------------
end if nn<50
eps=0;ierr=0;h=0;Mmax=0;err=0;
eps=magn_accur(M); lamb_err=1;
n=0; BIAS=NaN;SD=NaN; %%% K 08NOV2019
for i=1:length(M) return;
if M(i)>=Mmin; end
n=n+1;
x(n)=M(i); eps=magn_accur(M);
end n=0;
end for i=1:length(M)
x=sort(x)'; if M(i)>=Mmin;
beta=1/(mean(x)-Mmin+eps/2); n=n+1;
[xx]=korekta(x,Mmin,eps,beta); x(n)=M(i);
xx=sort(xx); end
clear x; end
xx = podwajanie(xx,Mmin-eps/2); x=sort(x)';
[h,ierr]=hopt(xx); beta=1/(mean(x)-Mmin+eps/2);
[ambd]=scaling(xx,h); [xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx);
if isempty(Mmax) %K30AUG2019 - Allow for manually set Mmax clear x;
[Mmax,err]=Mmaxest(xx,h,Mmin-eps/2); xx = podwajanie(xx,Mmin-eps/2);
else [h,ierr]=hopt(xx);
err=0; %K30AUG2019 [ambd]=scaling(xx,h);
end
% enai=dlmread('paraT.txt'); %for fixed xx,ambd to test in different platforms if isempty(Mmax) %K30AUG2019 - Allow for manually set Mmax
% [ambd]=enai(:,1); err_Mmax=1;[Mmax,err]=Mmaxest(xx,h,Mmin-eps/2); % err_Mmax added 04DEC2019
% xx=enai(:,2)'; else
% [h,ierr]=hopt(xx); err_Mmax=0;err=0; %K30AUG2019
% [Mmax,err]=Mmaxest(xx,h,Mmin-eps/2); end
end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 ---------------------------------- % Estimation of Mmax Bias %%% K 04DEC2019
% (Lasocki and Urban, 2011, doi:10.2478/s11600-010-0049-y)
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT if isempty(Nsynth)==0 && err_Mmax==1 % set number of synthetic datasets, e.g. 10000
% [BIAS,SD]=Mmax_Bias_GR(t,M,Mmin,Mmax,err,h,xx,ambd,Nsynth);
% t1 - start time (in MATLAB numerical format) elseif isempty(Nsynth)==0 && err_Mmax==0;
% t2 - end time (in MATLAB numerical format) t2>=t1 warning('Mmax must be empty for BIAS calculation');BIAS=[];SD=[];
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', else; BIAS=0;SD=0;
% iop=2 - 'year' end
%
% NM - number of time units from t1 to t2 end
% unit - string with name of time unit used ('year' or 'month' or 'day').
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 ----------------------------------
if iop==0
NM=(t2-t1); % TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
unit='day'; %
elseif iop==1 % t1 - start time (in MATLAB numerical format)
V1=datevec(t1); % t2 - end time (in MATLAB numerical format) t2>=t1
V2=datevec(t2); % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))... % iop=2 - 'year'
+(V2(1)-V1(1)-1)*12; %
unit='month'; % NM - number of time units from t1 to t2
else % unit - string with name of time unit used ('year' or 'month' or 'day').
V1=datevec(t1);
V2=datevec(t2); if iop==0
NM2=V2(3); NM=(t2-t1);
if V2(2)>1 unit='day';
for k=1:V2(2)-1 elseif iop==1
NM2=NM2+eomday(V2(1),k); V1=datevec(t1);
end V2=datevec(t2);
end NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
day2=365; if eomday(V2(1),2)==29; day2=366; end; +(V2(1)-V1(1)-1)*12;
NM2=NM2/day2; unit='month';
NM1=V1(3); else
if V1(2)>1 V1=datevec(t1);
for k=1:V1(2)-1 V2=datevec(t2);
NM1=NM1+eomday(V1(1),k); NM2=V2(3);
end if V2(2)>1
end for k=1:V2(2)-1
day1=365; if eomday(V1(1),2)==29; day1=366; end; NM2=NM2+eomday(V2(1),k);
NM1=(day1-NM1)/day1; end
NM=NM2+NM1+V2(1)-V1(1)-1; end
unit='year'; day2=365; if eomday(V2(1),2)==29; day2=366; end;
end NM2=NM2/day2;
end NM1=V1(3);
if V1(2)>1
function [m_corr]=korekta(m,Mmin,eps,beta) for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k);
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL end
% end
% m - input vector of magnitudes day1=365; if eomday(V1(1),2)==29; day1=366; end;
% Mmin - catalog completeness level NM1=(day1-NM1)/day1;
% eps - accuracy of magnitude NM=NM2+NM1+V2(1)-V1(1)-1;
% beta - the parameter of the unbounded exponential distribution unit='year';
% end
% m_corr - vector of randomized magnitudes end
%
F1=1-exp(-beta*(m-Mmin-0.5*eps)); function [m_corr]=korekta(m,Mmin,eps,beta)
F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m)); % RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
w=u.*(F2-F1)+F1; %
m_corr=Mmin-log(1-w)./beta; % m - input vector of magnitudes
end % Mmin - catalog completeness level
% eps - accuracy of magnitude
function x2 = podwajanie(x,x0) % beta - the parameter of the unbounded exponential distribution
%
% DOUBLES THE SAMPLE % m_corr - vector of randomized magnitudes
%
% If the sample x(i) is is truncated from the left hand side and belongs F1=1-exp(-beta*(m-Mmin-0.5*eps));
% to the interval [x0,inf) or it is truncated from the right hand side and F2=1-exp(-beta*(m-Mmin+0.5*eps));
% belongs to the interval (-inf,x0] u=rand(size(m));
% then the doubled sample is [-x(i)+2x0,x(i)] w=u.*(F2-F1)+F1;
% x - is the column data vector m_corr=Mmin-log(1-w)./beta;
% x2 - is the column vector of data doubled and sorted in the ascending end
% order
function x2 = podwajanie(x,x0)
x2=[-x+2*x0
x]; % DOUBLES THE SAMPLE
x2=sort(x2);
end % If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and
function [h,ierr]=hopt(x) % belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)]
%Estimation of the optimal smoothing factor by means of the least squares % x - is the column data vector
%method % x2 - is the column vector of data doubled and sorted in the ascending
% x - column data vector % order
% The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used x2=[-x+2*x0
% The function calls the procedure FZERO for the function 'funct' x];
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros x2=sort(x2);
% search end
% MODIFIED JUNE 2014 function [h,ierr]=hopt(x)
ierr=0; %Estimation of the optimal smoothing factor by means of the least squares
n=length(x); %method
x=sort(x); % x - column data vector
interval=[0.000001 2*std(x)/n^0.2]; % The result is an optimal smoothing factor
x1=funct(interval(1),x); % ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
x2=funct(interval(2),x); % The function calls the procedure FZERO for the function 'funct'
if x1*x2<0 % NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
fun = @(t) funct(t,x); % for octave % search
x0 =interval; % for octave
[hh(1),fval,exitflag] = fzero(fun,x0); % for octave % MODIFIED JUNE 2014
% Extra zeros search ierr=0;
jj=1; n=length(x);
for kk=2:7 x=sort(x);
interval(1)=1.1*hh(jj); interval=[0.000001 2*std(x)/n^0.2];
interval(2)=interval(1)+(kk-1)*hh(jj); x1=funct(interval(1),x);
x1=funct(interval(1),x); x2=funct(interval(2),x);
x2=funct(interval(2),x); if x1*x2<0
if x1*x2<0 fun = @(t) funct(t,x); % for octave
jj=jj+1; x0 =interval; % for octave
fun = @(t) funct(t,x); % for octave [hh(1),fval,exitflag] = fzero(fun,x0); % for octave
x0 =interval; % for octave
[hh(jj),fval,exitflag] = fzero(fun,x0); % for octave % Extra zeros search
end jj=1;
end for kk=2:7
if jj>1;ierr=1;end interval(1)=1.1*hh(jj);
h=max(hh); interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x);
if exitflag==1;return;end x2=funct(interval(2),x);
if x1*x2<0
end jj=jj+1;
h=0.891836*(mean(x)-x(1))/(n^0.2); fun = @(t) funct(t,x); % for octave
ierr=2; x0 =interval; % for octave
end [hh(jj),fval,exitflag] = fzero(fun,x0); % for octave
end
function [fct]=funct(t,x) end
p2=1.41421356; if jj>1;ierr=1;end
n=length(x); h=max(hh);
yy=zeros(size(x));
for i=1:n, if exitflag==1;return;end
xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1); end
yy(i)=sum(y); h=0.891836*(mean(x)-x(1))/(n^0.2);
end; ierr=2;
fct=sum(yy)-2*n; end
clear xij y yy;
end function [fct]=funct(t,x)
p2=1.41421356;
n=length(x);
function [ambd]=scaling(x,h) yy=zeros(size(x));
for i=1:n,
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE xij=(x-x(i)).^2/t^2;
% ESTIMATION y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y);
% x - the n dimensional column vector of data values sorted in the ascending end;
% order fct=sum(yy)-2*n;
% h - the optimal smoothing factor clear xij y yy;
% ambd - the resultant n dimensional row vector of local scaling factors end
n=length(x);
c=sqrt(2*pi); function [ambd]=scaling(x,h)
gau=zeros(1,n);
for i=1:n, % EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h; % ESTIMATION
end
g=exp(mean(log(gau))); % x - the n dimensional column vector of data values sorted in the ascending
ambd=sqrt(g./gau); % order
end % h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors
function [eps]=magn_accur(M)
x=sort(M); n=length(x);
d=x(2:length(x))-x(1:length(x)-1); c=sqrt(2*pi);
eps=min(d(d>0)); gau=zeros(1,n);
if eps>0.1; eps=0.1;end for i=1:n,
end gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end
function [Mmax,ierr]=Mmaxest(x,h,Mmin) g=exp(mean(log(gau)));
ambd=sqrt(g./gau);
% ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS end
% x - row vector of magnitudes (basic sample).
% h - optimal smoothing factor function [eps]=magn_accur(M)
% Mmax - upper bound x=sort(M);
% ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas d=x(2:length(x))-x(1:length(x)-1);
% estimation eps=min(d(d>0));
if eps>0.1; eps=0.1;end
% Uses function 'dystryb' end
n=length(x); function [Mmax,ierr]=Mmaxest(x,h,Mmin)
ierr=1;
x=sort(x); % ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS
Mmax1=x(n); % x - row vector of magnitudes (basic sample).
for i=1:50, % h - optimal smoothing factor
d=normcdf((Mmin-x)./h); % Mmax - upper bound
mian=sum(normcdf((Mmax1-x)./h)-d); % ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas
Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d); % estimation
if abs(Mmax-Mmax1)<0.01
ierr=0;break; % Uses function 'dystryb'
end
Mmax1=Mmax; n=length(x);
end ierr=1;
if (ierr==1 || Mmax>9) x=sort(x);
Mmax=2*x(n)-x(n-1); Mmax1=x(n);
ierr=1; for i=1:50,
end d=normcdf((Mmin-x)./h);
end mian=sum(normcdf((Mmax1-x)./h)-d);
Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d);
function [y]=dystryb(z,h,mian,x,d) if abs(Mmax-Mmax1)<0.01
n=length(x); ierr=0;break;
m=length(z); end
for i=1:m, Mmax1=Mmax;
t=(z(i)-x)./h; end
t=normcdf(t); if (ierr==1 || Mmax>9)
yy=sum(t-d); Mmax=2*x(n)-x(n-1);
y(i)=(yy/mian)^n; ierr=1;
end end
end end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin) function [y]=dystryb(z,h,mian,x,d)
n=length(x);
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY m=length(z);
for i=1:m,
% funfc - string with the name of function to be integrated t=(z(i)-x)./h;
% a,b - integration limits t=normcdf(t);
% eps - accurracy yy=sum(t-d);
% varargin - other parameters of function to be integrated y(i)=(yy/mian)^n;
% calka - integral end
% ier=0 - convergence, ier=1 - no conbergence end
persistent W X CONST function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ... % Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069]; % funfc - string with the name of function to be integrated
X=[0.960289856497536 0.796666477413627 0.525532409916329 ... % a,b - integration limits
0.183434642495650 0.989400934991650 0.944575023073233 ... % eps - accurracy
0.865631202387832 0.755404408355003 0.617876244402644 ... % varargin - other parameters of function to be integrated
0.458016777657227 0.281603550779259 0.095012509837637]; % calka - integral
CONST=1E-12; % ier=0 - convergence, ier=1 - no conbergence
delta=CONST*abs(a-b);
calka=0.; persistent W X CONST
aa=a; W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
y=b-aa; 0.362683783378362 0.027152459411754 0.062253523938648 ...
ier=0; 0.095158511682493 0.124628971255534 0.149595988816577 ...
while abs(y)>delta, 0.169156519395003 0.182603415044924 0.189450610455069];
bb=aa+y; X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
c1=0.5*(aa+bb); 0.183434642495650 0.989400934991650 0.944575023073233 ...
c2=c1-aa; 0.865631202387832 0.755404408355003 0.617876244402644 ...
s8=0.; 0.458016777657227 0.281603550779259 0.095012509837637];
s16=0.; CONST=1E-12;
for i=1:4, delta=CONST*abs(a-b);
u=X(i)*c2; calka=0.;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); aa=a;
end y=b-aa;
for i=5:12, ier=0;
u=X(i)*c2; while abs(y)>delta,
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); bb=aa+y;
end c1=0.5*(aa+bb);
s8=s8*c2; c2=c1-aa;
s16=s16*c2; s8=0.;
if abs(s16-s8)>eps*(1+abs(s16)) s16=0.;
y=0.5*y; for i=1:4,
calka=0.; u=X(i)*c2;
ier=1; s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
else end
calka=calka+s16; for i=5:12,
aa=bb; u=X(i)*c2;
y=b-aa; s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
ier=0; end
end s8=s8*c2;
end s16=s16*c2;
end if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y;
calka=0.;
ier=1;
else
calka=calka+s16;
aa=bb;
y=b-aa;
ier=0;
end
end
end
% --------------------- Mmax BIAS estimation routine ---------------------- K 08NOV2019
function [BIAS,SD]=Mmax_Bias_GR(t,m,Mc,Mmax1,err,h,xx,ambd,synth)
s1=sort(unique(m));s2=s1(2:length(s1))-s1(1:length(s1)-1);EPS=min(s2);
if err~=0
warning('process did not converge!!')
end
MAXm=max(m);N=numel(m(m>=Mc));DeltaM=MAXm-Mc; %beta=b*log(10);
[mag,PDF_NPT,CDF_NPT]=dist_NPT(Mc-EPS,Mmax1+EPS,0.01,Mc,EPS,h,xx,ambd,Mmax1);
for j=1:synth %set number of synthetic datasets, default is 10000
% % CDF:
% j
% linear interpolation to assign magnitude values from a uniform distribution sample
iM=rand(1,N);M1=interp1q(CDF_NPT,mag,iM');
br(j)=1/(log(10)*(mean(M1)-min(M1)+EPS/2));DM=range(M1);
Mmax=max(M1);
% Iteration Process to estimate b and Mmax
b1=10;best=[1.0 10.0];i=1;
while min(abs(diff(best)))>0.00001
w=exp(b1*(Mmax-Mc));E1=expint(N/(w-1));E2=expint(N*w/(w-1));
%E=expint(w);
Mme=Mmax+(E1-E2)/(b1*exp(-N/(w-1)))+(Mc)*exp(-N); %Mme=round(Mme/EPS)*EPS;
if isnan(Mme)
KM=sort(unique(M1),'descend');
Mme=2*KM(1)-KM(2);
end
fun=@(bb) 1/bb+(Mme-Mc)/(1-exp(bb*(Mme-Mc)))-mean(M1)+Mc-EPS/2; %consider th5 last 0.05 term
b1=fzero(fun,1);best(i)=b1;i=i+1;
if i==50
warning('process did not converge!!');break
end
end
be(j)=b1/log(10);
Me(j)=Mme;dm(j)=DM;Mm(j)=Mmax;
end
BIAS=mean(MAXm-Me);
SD=std(MAXm-Me);
%b-mean(be) %check b-value difference
%histogram(be)
% MAXm: maximum magnitude in the real catalog
% Mmax: maximum magnitudes observed in the synthetic catalogs (rounded)
% Me: maximum magnitude estimates for the synthetic catalogs
% Mmax1: maximum magnitude estimated by GRT
end

View File

@@ -1,83 +1,83 @@
% [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax) % [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax)
% %
% EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UPPER-BOUNDED G-R LED % EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UPPER-BOUNDED G-R LED
% MAGNITUDE DISTRIBUTION MODEL. % MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R % Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the % b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the % activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded % stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode. % Gutenberg-Richter estimation mode.
% %
% The mean return period of magnitude M is the average elapsed time between % The mean return period of magnitude M is the average elapsed time between
% the consecutive earthquakes of magnitude M. % the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up % The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM. % to Mu with step dM.
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes % M - vector of earthquake magnitudes
% Md - starting magnitude for return period calculations % Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations % Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations % dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% OUTPUT: % OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu) % m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m % T - vector od mean return periods of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax) function [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
if Md<Mmin; Md=Mmin;end if Md<Mmin; Md=Mmin;end
if Mu>Mmax; Mu=Mmax;end if Mu>Mmax; Mu=Mmax;end
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
beta=b*log(10); beta=b*log(10);
T=1/lamb./(1-Cdfgr(m,beta,Mmin-eps/2,Mmax)); T=1/lamb./(1-Cdfgr(m,beta,Mmin-eps/2,Mmax));
end end
function [y]=Cdfgr(t,beta,Mmin,Mmax) function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R %CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model % model
% Mmin - catalog completeness level % Mmin - catalog completeness level
% Mmax - upper limit of the distribution % Mmax - upper limit of the distribution
% beta - the distribution parameter % beta - the distribution parameter
% t - vector of magnitudes (independent variable) % t - vector of magnitudes (independent variable)
% y - CDF vector % y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin))); mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian; y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1); idx=find(y>1);
y(idx)=ones(size(idx)); y(idx)=ones(size(idx));
end end

View File

@@ -1,59 +1,59 @@
% [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b) % [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b)
% %
% EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UNLIMITED G-R LED % EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UNLIMITED G-R LED
% MAGNITUDE DISTRIBUTION MODEL. % MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation % DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution % leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of % from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at % this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the % start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode. % unlimited Gutenberg-Richter estimation mode.
% %
% The mean return period of magnitude M is the average elapsed time between % The mean return period of magnitude M is the average elapsed time between
% the consecutive earthquakes of magnitude M. % the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up % The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM. % to Mu with step dM.
% %
%INPUT: %INPUT:
% Md - starting magnitude for return period calculations % Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations % Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations % dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% %
%OUTPUT: %OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu) % m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m % T - vector od mean return periods of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b) function [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
if Md<Mmin; Md=Mmin;end if Md<Mmin; Md=Mmin;end
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
beta=b*log(10); beta=b*log(10);
T=1/lamb./exp(-beta*(m-Mmin+eps/2)); T=1/lamb./exp(-beta*(m-Mmin+eps/2));
end end

View File

@@ -1,94 +1,94 @@
% [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax) % [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax)
% %
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MEAN %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MEAN
% RETURN PERIOD VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC % RETURN PERIOD VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE. % DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand % the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters % side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off % namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the % interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of % scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the % magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with % randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2. % respect to the value Mmin-eps/2.
% %
% The mean return periods are calculated for magnitude starting from Md up % The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM. % to Mu with step dM.
% %
% REFERENCES: % REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, % Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 % Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 % Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% Md - starting magnitude for return period calculations % Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations % Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations % dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu) % m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m % T - vector od mean return periods of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax) function [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
if Md<Mmin; Md=Mmin;end if Md<Mmin; Md=Mmin;end
if Mu>Mmax; Mu=Mmax;end if Mu>Mmax; Mu=Mmax;end
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
n=length(m); n=length(m);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
for i=1:n for i=1:n
CDF_NPT=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian; CDF_NPT=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian;
T(i)=1/lamb./(1-CDF_NPT); T(i)=1/lamb./(1-CDF_NPT);
end end
T=T'; T=T';
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,91 +1,91 @@
% [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd) % [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MEAN RETURN PERIOD VALUES FOR THE UNBOUNDED % THE MEAN RETURN PERIOD VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE. % NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side. % the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel % The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the % estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample % scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled % - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2. % symmetrically with respect to the value Mmin-eps/2.
% %
% The mean return period of magnitude M is the average % The mean return period of magnitude M is the average
% elapsed time between the consecutive earthquakes of magnitude M. % elapsed time between the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up % The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM. % to Mu with step dM.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% Md - starting magnitude for return period calculations % Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations % Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations % dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
%OUTPUT: %OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu) % m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m % T - vector od mean return periods of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd) function [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
if Md<Mmin; Md=Mmin;end if Md<Mmin; Md=Mmin;end
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
n=length(m); n=length(m);
for i=1:n for i=1:n
CDF_NPU=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); CDF_NPU=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
T(i)=1/lamb./(1-CDF_NPU); T(i)=1/lamb./(1-CDF_NPU);
end end
T=T'; T=T';
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,250 +1,250 @@
% %
% [lamb_all,lamb,lmab_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin) % [lamb_all,lamb,lmab_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin)
% %
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE % ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE, % COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE,
% THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE % THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE
% DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL % DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !! % GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution and consequently the G-R % Mmin. The shape parameter of this distribution and consequently the G-R
% b-value is estimated by maximum likelihood method (Aki-Utsu procedure). % b-value is estimated by maximum likelihood method (Aki-Utsu procedure).
% The upper limit of the distribution Mmax is evaluated using % The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the % the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used: % Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)). % Mmaxest= 2(max obs M) - (second max obs M)).
% The mean activity rate, lamb, is the number of events >=Mmin into the % The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input % length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year. % parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps is the least non-zero difference % The round-off interval length - eps is the least non-zero difference
% between sample data or 0.1 if the least difference is greater than 0.1. % between sample data or 0.1 if the least difference is greater than 0.1.
% %
% REFERENCES: % REFERENCES:
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654 %Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673, %Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y % doi: 10.2478/s11600-010-0049-y
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog % M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally. % Mmin - catalog completeness level. Must be determined externally.
% Can take any value from [min(M), max(M)]. % Can take any value from [min(M), max(M)].
% %
% OUTPUT: % OUTPUT:
% %
% lamb_all - mean activity rate for all events % lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin % lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 15 or more events >=Mmin and the parameter estimation is % for 15 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except % continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is % lamb_all and lamb are set to zero and the function execution is
% terminated. % terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 - % err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock % no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used. % method used.
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin) function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin)
n=length(M); n=length(M);
lamb_err=0; lamb_err=0;
t1=t(1); t1=t(1);
for i=1:n for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t1=t(i+1); t1=t(i+1);
end end
t2=t(n); t2=t(n);
for i=n:1 for i=n:1
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t2=t(i-1);
end end
nn=0; nn=0;
for i=1:n for i=1:n
if M(i)>=Mmin if M(i)>=Mmin
nn=nn+1; nn=nn+1;
end end
end end
if iop==0 if iop==0
lamb_all=n/round(t(n)-t(1)); lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1); lamb=nn/round(t2-t1);
unit='day'; unit='day';
elseif iop==1 elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014 lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014 lamb=30*nn/(t2-t1); % K20OCT2014
unit='month'; unit='month';
else else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014 lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014 lamb=365*nn/(t2-t1); % K20OCT2014
unit='year'; unit='year';
end end
if nn<15 if nn<15
eps=0;b=0;Mmax=0;err=0; eps=0;b=0;Mmax=0;err=0;
lamb_err=1; lamb_err=1;
return; return;
end end
eps=magn_accur(M); eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014 xx=M(M>=Mmin); %K21OCT2014
% x=sort(M,'descend'); % x=sort(M,'descend');
% for i=1:n % for i=1:n
% if x(i)<Mmin; break; end % if x(i)<Mmin; break; end
% xx(i)=x(i); % % xx(i)=x(i); %
% end % end
clear x; clear x;
nn=length(xx); nn=length(xx);
Max_obs=max(xx); Max_obs=max(xx);
beta0=0; beta0=0;
Mmax1=Max_obs; Mmax1=Max_obs;
for i=1:50, for i=1:50,
beta=fzero(@bet_est,[0.05,4.0],[],mean(xx),Mmin-eps/2,Mmax1); beta=fzero(@bet_est,[0.05,4.0],[],mean(xx),Mmin-eps/2,Mmax1);
Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1); Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1);
if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001)) if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001))
err=0; err=0;
break; break;
end end
Mmax1=Mmax; Mmax1=Mmax;
beta0=beta; beta0=beta;
end end
if i==50; if i==50;
err=1.0; err=1.0;
Mmax=2*xx(1)-xx(2); Mmax=2*xx(1)-xx(2);
beta=fzero(@bet_est,1.0,[],mean(xx),Mmin-eps/2,Mmax); beta=fzero(@bet_est,1.0,[],mean(xx),Mmin-eps/2,Mmax);
end end
b=beta/log(10); b=beta/log(10);
clear xx clear xx
end end
function [zero]=bet_est(b,ms,Mmin,Mmax) function [zero]=bet_est(b,ms,Mmin,Mmax)
%First derivative of the log likelihood function of the upper-bounded %First derivative of the log likelihood function of the upper-bounded
% exponential distribution (truncated GR model) % exponential distribution (truncated GR model)
% b - parameter of the distribution 'beta' % b - parameter of the distribution 'beta'
% ms - mean of the observed magnitudes % ms - mean of the observed magnitudes
% Mmin - catalog completeness level % Mmin - catalog completeness level
% Mmax - upper limit of the distribution % Mmax - upper limit of the distribution
M_max_min=Mmax-Mmin; M_max_min=Mmax-Mmin;
e_m=exp(-b*M_max_min); e_m=exp(-b*M_max_min);
zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m); zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m);
end end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin) function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY % Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated % funfc - string with the name of function to be integrated
% a,b - integration limits % a,b - integration limits
% eps - accurracy % eps - accurracy
% varargin - other parameters of function to be integrated % varargin - other parameters of function to be integrated
% calka - integral % calka - integral
% ier=0 - convergence, ier=1 - no conbergence % ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ... W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ... 0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ... 0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069]; 0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ... X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ... 0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ... 0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637]; 0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12; CONST=1E-12;
delta=CONST*abs(a-b); delta=CONST*abs(a-b);
calka=0.; calka=0.;
aa=a; aa=a;
y=b-aa; y=b-aa;
ier=0; ier=0;
while abs(y)>delta, while abs(y)>delta,
bb=aa+y; bb=aa+y;
c1=0.5*(aa+bb); c1=0.5*(aa+bb);
c2=c1-aa; c2=c1-aa;
s8=0.; s8=0.;
s16=0.; s16=0.;
for i=1:4, for i=1:4,
u=X(i)*c2; u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end end
for i=5:12, for i=5:12,
u=X(i)*c2; u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end end
s8=s8*c2; s8=s8*c2;
s16=s16*c2; s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16)) if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y; y=0.5*y;
calka=0.; calka=0.;
ier=1; ier=1;
else else
calka=calka+s16; calka=calka+s16;
aa=bb; aa=bb;
y=b-aa; y=b-aa;
ier=0; ier=0;
end end
end end
end end
function [y]=f_podc(z,n,beta,Mmin,Mmax) function [y]=f_podc(z,n,beta,Mmin,Mmax)
% Integrated function for Mmax estimation. Truncated GR model % Integrated function for Mmax estimation. Truncated GR model
% z - column vector of independent variable % z - column vector of independent variable
% n - the size of 'z' % n - the size of 'z'
% beta - the distribution parameter % beta - the distribution parameter
% Mmin - the catalog completeness level % Mmin - the catalog completeness level
% Mmax - the upper limit of the distribution % Mmax - the upper limit of the distribution
y=Cdfgr(z,beta,Mmin,Mmax).^n; y=Cdfgr(z,beta,Mmin,Mmax).^n;
end end
function [y]=Cdfgr(t,beta,Mmin,Mmax) function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R %CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model % model
% Mmin - catalog completeness level % Mmin - catalog completeness level
% Mmax - upper limit of the distribution % Mmax - upper limit of the distribution
% beta - the distribution parameter % beta - the distribution parameter
% t - vector of magnitudes (independent variable) % t - vector of magnitudes (independent variable)
% y - CDF vector % y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin))); mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian; y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1); idx=find(y>1);
y(idx)=ones(size(idx)); y(idx)=ones(size(idx));
end end
function [eps]=magn_accur(M) function [eps]=magn_accur(M)
x=sort(M); x=sort(M);
d=x(2:length(x))-x(1:length(x)-1); d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); eps=min(d(d>0));
if eps>0.1; eps=0.1;end if eps>0.1; eps=0.1;end
end end

View File

@@ -1,305 +1,387 @@
% %
% [lamb_all,lamb,lmab_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin) %[lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err,BIAS,SD]=TruncGR_Ob(t,M,iop,Mmin,Mmax,Nsynth)
% %
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE % ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE, % COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE,
% THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE % THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE
% DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL % DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !! % GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project. % AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution and consequently the G-R % Mmin. The shape parameter of this distribution and consequently the G-R
% b-value is estimated by maximum likelihood method (Aki-Utsu procedure). % b-value is estimated by maximum likelihood method (Aki-Utsu procedure).
% The upper limit of the distribution Mmax is evaluated using % The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the % the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used: % Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)). % Mmaxest= 2(max obs M) - (second max obs M)).
% The mean activity rate, lamb, is the number of events >=Mmin into the % The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input % length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year. % parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps is the least non-zero difference % The round-off interval length - eps is the least non-zero difference
% between sample data or 0.1 if the least difference is greater than 0.1. % between sample data or 0.1 if the least difference is greater than 0.1.
% %
% REFERENCES: % REFERENCES:
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654 %Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673, %Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y % doi: 10.2478/s11600-010-0049-y
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog % M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally. % Mmin - catalog completeness level. Must be determined externally.
% Can take any value from [min(M), max(M)]. % Can take any value from [min(M), max(M)].
% % Mmax - upper limit of Magnitude Distribution. Can be set by user, or
% OUTPUT: % estimate within the program - it then should be set as Mmax=[].
% %
% lamb_all - mean activity rate for all events % OUTPUT:
% lamb - mean activity rate for events >= Mmin %
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_all - mean activity rate for all events
% for 15 or more events >=Mmin and the parameter estimation is % lamb - mean activity rate for events >= Mmin
% continued, lamb_err=1 otherwise, all output paramters except % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% lamb_all and lamb are set to zero and the function execution is % for 15 or more events >=Mmin and the parameter estimation is
% terminated. % continued, lamb_err=1 otherwise, all output paramters except
% unit - string with name of time unit used ('year' or 'month' or 'day'). % lamb_all and lamb are set to zero and the function execution is
% eps - length of the round-off interval of magnitudes. % terminated.
% b - Gutenberg-Richter b-value % unit - string with name of time unit used ('year' or 'month' or 'day').
% Mmax - upper limit of magnitude distribution % eps - length of the round-off interval of magnitudes.
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 - % b - Gutenberg-Richter b-value
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock % Mmax - upper limit of magnitude distribution
% method used. % err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% % no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% LICENSE % method used.
% This file is a part of the IS-EPOS e-PLATFORM. % BIAS - Mmax estimation Bias (Lasocki and Urban, 2011)
% % SD - Mmax standard deviation (Lasocki ands Urban, 2011)
% This is free software: you can redistribute it and/or modify it under %
% the terms of the GNU General Public License as published by the Free % LICENSE
% Software Foundation, either version 3 of the License, or % This file is a part of the IS-EPOS e-PLATFORM.
% (at your option) any later version. %
% % This is free software: you can redistribute it and/or modify it under
% This program is distributed in the hope that it will be useful, % the terms of the GNU General Public License as published by the Free
% but WITHOUT ANY WARRANTY; without even the implied warranty of % Software Foundation, either version 3 of the License, or
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % (at your option) any later version.
% GNU General Public License for more details. %
% % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err]=TruncGR_O(t,M,iop,Mmin,Mmax) % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT % GNU General Public License for more details.
t=[1 2];M=[1 2]; end %K30SEP %
n=length(M); function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err,BIAS,SD]=TruncGR_Ob(t,M,iop,Mmin,Mmax,Nsynth)
lamb_err=0; if nargin==5;Nsynth=[];end % K08DEC2019
t1=t(1); if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT
for i=1:n t=[1 2];M=[1 2]; end %K30SEP
if M(i)>=Mmin; break; end
t1=t(i+1); n=length(M);
end lamb_err=0;
t2=t(n); t1=t(1);
for i=n:1 for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t1=t(i+1);
end end
nn=0; t2=t(n);
for i=1:n for i=n:1
if M(i)>=Mmin if M(i)>=Mmin; break; end
nn=nn+1; t2=t(i-1);
end end
end nn=0;
for i=1:n
% SL 03MAR2015 ---------------------------------- if M(i)>=Mmin
[NM,unit]=time_diff(t(1),t(n),iop); nn=nn+1;
lamb_all=n/NM; end
[NM,unit]=time_diff(t1,t2,iop); end
lamb=nn/NM;
% SL 03MAR2015 ---------------------------------- % SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop);
if nn<15 lamb_all=n/NM;
eps=0;b=0;Mmax=0;err=0; [NM,unit]=time_diff(t1,t2,iop);
lamb_err=1; lamb=nn/NM;
return; % SL 03MAR2015 ----------------------------------
end
if nn<15
eps=magn_accur(M); eps=0;b=0;Mmax=0;err=0;
xx=M(M>=Mmin); %K21OCT2014 lamb_err=1;
% x=sort(M,'descend'); BIAS=NaN;SD=NaN; %%% K 08NOV2019
% for i=1:n return;
% if x(i)<Mmin; break; end end
% xx(i)=x(i); %
% end eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014
clear x; % x=sort(M,'descend');
nn=length(xx); % for i=1:n
% if x(i)<Mmin; break; end
Max_obs=max(xx); % xx(i)=x(i); %
beta0=0; % end
Mmax1=Max_obs;
if isempty(Mmax)==0 %%% K 28JUL2015 clear x;
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax); %%% K 28JUL2015 nn=length(xx);
x0 = 1; %[0.05,4.0]; %%% K 28JUL2015 - See exception line 153
beta = fzero(fun,x0); %%% K 28JUL2015 Max_obs=max(xx);
err=0; %%% K 28JUL2015 beta0=0;
else %%% K 28JUL2015 - line 148 Mmax1=Max_obs;
for i=1:50, if isempty(Mmax)==0 %%% K 28JUL2015
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax1); err_Mmax=0; %%% K 04DEC2019
x0 =1; %[0.05,4.0]; %%% K29JUL2015 - See exception line 153 fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax); %%% K 28JUL2015
beta = fzero(fun,x0); x0 = 1; %[0.05,4.0]; %%% K 28JUL2015 - See exception line 155
Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1); beta = fzero(fun,x0); %%% K 28JUL2015
if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001)) err=0; %%% K 28JUL2015
err=0; else %%% K 28JUL2015 - line 150
break; err_Mmax=1; %%% K 04DEC2019
end for i=1:50,
Mmax1=Mmax; fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax1);
beta0=beta; x0 =1; %[0.05,4.0]; %%% K29JUL2015 - See exception line 155
end beta = fzero(fun,x0);
if i==50; Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1);
err=1.0; if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001))
Mmax=2*xx(1)-xx(2); err=0;
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax); break;
x0 =1; end
beta = fzero(fun,x0); Mmax1=Mmax;
end beta0=beta;
end %%% K 28JUL2015 end
b=beta/log(10); if i==50;
clear xx err=1.0;
Mmax=2*xx(1)-xx(2);
% Exception for v-value fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax);
if b<0.05 || b>6.0; error('Unacceptable b-value, abort and select different dataset');end x0 =1;
beta; beta = fzero(fun,x0);
end end
end %%% K 28JUL2015
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 b=beta/log(10);
clear xx
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
% % Exception for v-value
% t1 - start time (in MATLAB numerical format) if b<0.05 || b>6.0; error('Unacceptable b-value, abort and select different dataset');end
% t2 - end time (in MATLAB numerical format) t2>=t1 beta;
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% % Estimation of Mmax Bias %%% K 04DEC2019
% NM - number of time units from t1 to t2 % (Lasocki and Urban, 2011, doi:10.2478/s11600-010-0049-y)
% unit - string with name of time unit used ('year' or 'month' or 'day'). if isempty(Nsynth)==0 && err_Mmax==1 % set number of synthetic datasets, e.g. 10000
[BIAS,SD]=Mmax_Bias_GR(t,M,Mmin,Mmax,b,err,Nsynth);
if iop==0 elseif isempty(Nsynth)==0 && err_Mmax==0;
NM=(t2-t1); warning('Mmax must be empty for BIAS calculation');BIAS=[];SD=[];
unit='day'; else; BIAS=0;SD=0;
elseif iop==1 end
V1=datevec(t1);
V2=datevec(t2); end
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12;
unit='month';
else
V1=datevec(t1); function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
V2=datevec(t2);
NM2=V2(3); % TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
if V2(2)>1 %
for k=1:V2(2)-1 % t1 - start time (in MATLAB numerical format)
NM2=NM2+eomday(V2(1),k); % t2 - end time (in MATLAB numerical format) t2>=t1
end % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
end % iop=2 - 'year'
day2=365; if eomday(V2(1),2)==29; day2=366; end; %
NM2=NM2/day2; % NM - number of time units from t1 to t2
NM1=V1(3); % unit - string with name of time unit used ('year' or 'month' or 'day').
if V1(2)>1
for k=1:V1(2)-1 if iop==0
NM1=NM1+eomday(V1(1),k); NM=(t2-t1);
end unit='day';
end elseif iop==1
day1=365; if eomday(V1(1),2)==29; day1=366; end; V1=datevec(t1);
NM1=(day1-NM1)/day1; V2=datevec(t2);
NM=NM2+NM1+V2(1)-V1(1)-1; NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
unit='year'; +(V2(1)-V1(1)-1)*12;
end unit='month';
end else
V1=datevec(t1);
function [zero]=bet_est(b,ms,Mmin,Mmax) V2=datevec(t2);
NM2=V2(3);
%First derivative of the log likelihood function of the upper-bounded if V2(2)>1
% exponential distribution (truncated GR model) for k=1:V2(2)-1
% b - parameter of the distribution 'beta' NM2=NM2+eomday(V2(1),k);
% ms - mean of the observed magnitudes end
% Mmin - catalog completeness level end
% Mmax - upper limit of the distribution day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2;
M_max_min=Mmax-Mmin; NM1=V1(3);
e_m=exp(-b*M_max_min); if V1(2)>1
zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m); for k=1:V1(2)-1
end NM1=NM1+eomday(V1(1),k);
end
end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin) day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1;
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year';
% funfc - string with the name of function to be integrated end
% a,b - integration limits end
% eps - accurracy
% varargin - other parameters of function to be integrated function [zero]=bet_est(b,ms,Mmin,Mmax)
% calka - integral
% ier=0 - convergence, ier=1 - no conbergence %First derivative of the log likelihood function of the upper-bounded
% exponential distribution (truncated GR model)
persistent W X CONST % b - parameter of the distribution 'beta'
W=[0.101228536290376 0.222381034453374 0.313706645877887 ... % ms - mean of the observed magnitudes
0.362683783378362 0.027152459411754 0.062253523938648 ... % Mmin - catalog completeness level
0.095158511682493 0.124628971255534 0.149595988816577 ... % Mmax - upper limit of the distribution
0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ... M_max_min=Mmax-Mmin;
0.183434642495650 0.989400934991650 0.944575023073233 ... e_m=exp(-b*M_max_min);
0.865631202387832 0.755404408355003 0.617876244402644 ... zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m);
0.458016777657227 0.281603550779259 0.095012509837637]; end
CONST=1E-12;
delta=CONST*abs(a-b);
calka=0.; function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
aa=a;
y=b-aa; % Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
ier=0;
while abs(y)>delta, % funfc - string with the name of function to be integrated
bb=aa+y; % a,b - integration limits
c1=0.5*(aa+bb); % eps - accurracy
c2=c1-aa; % varargin - other parameters of function to be integrated
s8=0.; % calka - integral
s16=0.; % ier=0 - convergence, ier=1 - no conbergence
for i=1:4,
u=X(i)*c2; persistent W X CONST
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
end 0.362683783378362 0.027152459411754 0.062253523938648 ...
for i=5:12, 0.095158511682493 0.124628971255534 0.149595988816577 ...
u=X(i)*c2; 0.169156519395003 0.182603415044924 0.189450610455069];
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
end 0.183434642495650 0.989400934991650 0.944575023073233 ...
s8=s8*c2; 0.865631202387832 0.755404408355003 0.617876244402644 ...
s16=s16*c2; 0.458016777657227 0.281603550779259 0.095012509837637];
if abs(s16-s8)>eps*(1+abs(s16)) CONST=1E-12;
y=0.5*y; delta=CONST*abs(a-b);
calka=0.; calka=0.;
ier=1; aa=a;
else y=b-aa;
calka=calka+s16; ier=0;
aa=bb; while abs(y)>delta,
y=b-aa; bb=aa+y;
ier=0; c1=0.5*(aa+bb);
end c2=c1-aa;
end s8=0.;
end s16=0.;
for i=1:4,
function [y]=f_podc(z,n,beta,Mmin,Mmax) u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
% Integrated function for Mmax estimation. Truncated GR model end
% z - column vector of independent variable for i=5:12,
% n - the size of 'z' u=X(i)*c2;
% beta - the distribution parameter s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
% Mmin - the catalog completeness level end
% Mmax - the upper limit of the distribution s8=s8*c2;
s16=s16*c2;
y=Cdfgr(z,beta,Mmin,Mmax).^n; if abs(s16-s8)>eps*(1+abs(s16))
end y=0.5*y;
calka=0.;
function [y]=Cdfgr(t,beta,Mmin,Mmax) ier=1;
else
%CDF of the truncated upper-bounded exponential distribution (truncated G-R calka=calka+s16;
% model aa=bb;
% Mmin - catalog completeness level y=b-aa;
% Mmax - upper limit of the distribution ier=0;
% beta - the distribution parameter end
% t - vector of magnitudes (independent variable) end
% y - CDF vector end
mian=(1-exp(-beta*(Mmax-Mmin))); function [y]=f_podc(z,n,beta,Mmin,Mmax)
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1); % Integrated function for Mmax estimation. Truncated GR model
y(idx)=ones(size(idx)); % z - column vector of independent variable
end % n - the size of 'z'
% beta - the distribution parameter
function [eps]=magn_accur(M) % Mmin - the catalog completeness level
x=sort(M); % Mmax - the upper limit of the distribution
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); y=Cdfgr(z,beta,Mmin,Mmax).^n;
if eps>0.1; eps=0.1;end end
end
function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
% beta - the distribution parameter
% t - vector of magnitudes (independent variable)
% y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1);
y(idx)=ones(size(idx));
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end
% --------------------- Mmax BIAS estimation routine ---------------------- K 08NOV2019
function [BIAS,SD]=Mmax_Bias_GR(t,m,Mc,Mmax1,b,err,synth)
if err~=0
warning('process did not converge!!'),pause
end
MAXm=max(m);beta=b*log(10);N=numel(m(m>=Mc));DeltaM=MAXm-Mc;
for j=1:synth %set number of synthetic datasets, default is 10000
% % CDF:
M=Mc:0.0001:MAXm;upt=1-exp(-beta*(M-Mc));
dwt=1-exp(-beta*(MAXm-Mc));F=upt./dwt; % j
% linear interpolation to assign magnitude values from a uniform distribution sample
iM=rand(1,N);M1=interp1q(F',M',iM');
br(j)=1/(log(10)*(mean(M1)-min(M1)));DM=range(M1);
Mmax=max(M1);
% Iteration Process to estimate b and Mmax
b1=1;best=[1.0 10.0];i=1;
while min(abs(diff(best)))>0.00001
w=exp(b1*(Mmax-Mc));E1=expint(N/(w-1));E2=expint(N*w/(w-1));
%E=expint(w);
Mme=Mmax+(E1-E2)/(b1*exp(-N/(w-1)))+(Mc)*exp(-N); %Mme=round(Mme/EPS)*EPS;
if isnan(Mme)
KM=sort(unique(M1),'descend');
Mme=2*KM(1)-KM(2);
end
fun=@(bb) 1/bb+(Mme-Mc)/(1-exp(bb*(Mme-Mc)))-mean(M1)+Mc; %consider th5 last 0.05 term
b1=fzero(fun,1);best(i)=b1;i=i+1;
if i==50
warning('process did not converge!!');break
end
end
be(j)=b1/log(10);
Me(j)=Mme;dm(j)=DM;Mm(j)=Mmax;
end
BIAS=mean(MAXm-Me)
SD=std(MAXm-Me);
%b-mean(be) %check b-value difference
%histogram(be)
% MAXm: maximum magnitude in the real catalog
% Mmax: maximum magnitudes observed in the synthetic catalogs (rounded)
% Me: maximum magnitude estimates for the synthetic catalogs
% Mmax1: maximum magnitude estimated by GRT
end

View File

@@ -1,162 +1,162 @@
% [lamb_all,lamb,lmab_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin) % [lamb_all,lamb,lmab_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin)
% %
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE % ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE AND THE % COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE AND THE
% GUTENBERG-RICHTER B-VALUE USING THE UNLIMITED G-R LED MAGNITUDE % GUTENBERG-RICHTER B-VALUE USING THE UNLIMITED G-R LED MAGNITUDE
% DISTRIBUTION MODEL % DISTRIBUTION MODEL
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !! % GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project. % AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation % DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution % leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of % from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value is estimated by % this distribution and consequently the G-R b-value is estimated by
% maximum likelihood method (Aki-Utsu procedure). % maximum likelihood method (Aki-Utsu procedure).
% The mean activity rate, lamb, is the number of events >=Mmin into the % The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input % length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year. % parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps if the least non-zero difference % The round-off interval length - eps if the least non-zero difference
% between sample data or 0.1 is the least difference is greater than 0.1. % between sample data or 0.1 is the least difference is greater than 0.1.
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog % M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally. % Mmin - catalog completeness level. Must be determined externally.
% can take any value from [min(M), max(M)]. % can take any value from [min(M), max(M)].
% %
% OUTPUT: % OUTPUT:
% lamb_all - mean activity rate for all events % lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin % lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 7 or more events >=Mmin and the parameter estimation is % for 7 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except % continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is % lamb_all and lamb are set to zero and the function execution is
% terminated. % terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>. % along with this program. If not, see <http://www.gnu.org/licenses/>.
% %
function [lamb_all,lamb,lamb_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin) function [lamb_all,lamb,lamb_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin)
if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP t=[1 2];M=[1 2]; end %K30SEP
lamb_err=0; lamb_err=0;
n=length(M); n=length(M);
t1=t(1); t1=t(1);
for i=1:n for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t1=t(i+1); t1=t(i+1);
end end
t2=t(n); t2=t(n);
for i=n:1 for i=n:1
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t2=t(i-1);
end end
nn=0; nn=0;
for i=1:n for i=1:n
if M(i)>=Mmin if M(i)>=Mmin
nn=nn+1; nn=nn+1;
end end
end end
% SL 03MAR2015 ---------------------------------- % SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop); [NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM; lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop); [NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM; lamb=nn/NM;
% SL 03MAR2015 ---------------------------------- % SL 03MAR2015 ----------------------------------
if nn<7 if nn<7
eps=0;b=0; eps=0;b=0;
lamb_err=1; lamb_err=1;
return; return;
end end
eps=magn_accur(M); eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014 xx=M(M>=Mmin); %K21OCT2014
% x=sort(M,'descend'); % x=sort(M,'descend');
% for i=1:n % for i=1:n
% if x(i)<Mmin; break; end % if x(i)<Mmin; break; end
% xx(i)=x(i); % % xx(i)=x(i); %
% end % end
clear x; clear x;
beta=1/(mean(xx)-Mmin+eps/2); beta=1/(mean(xx)-Mmin+eps/2);
b=beta/log(10); b=beta/log(10);
clear xx clear xx
end end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT % TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
% %
% t1 - start time (in MATLAB numerical format) % t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1 % t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% %
% NM - number of time units from t1 to t2 % NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0 if iop==0
NM=(t2-t1); NM=(t2-t1);
unit='day'; unit='day';
elseif iop==1 elseif iop==1
V1=datevec(t1); V1=datevec(t1);
V2=datevec(t2); V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))... NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12; +(V2(1)-V1(1)-1)*12;
unit='month'; unit='month';
else else
V1=datevec(t1); V1=datevec(t1);
V2=datevec(t2); V2=datevec(t2);
NM2=V2(3); NM2=V2(3);
if V2(2)>1 if V2(2)>1
for k=1:V2(2)-1 for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k); NM2=NM2+eomday(V2(1),k);
end end
end end
day2=365; if eomday(V2(1),2)==29; day2=366; end; day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2; NM2=NM2/day2;
NM1=V1(3); NM1=V1(3);
if V1(2)>1 if V1(2)>1
for k=1:V1(2)-1 for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k); NM1=NM1+eomday(V1(1),k);
end end
end end
day1=365; if eomday(V1(1),2)==29; day1=366; end; day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1; NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1; NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year'; unit='year';
end end
end end
function [eps]=magn_accur(M) function [eps]=magn_accur(M)
x=sort(M); x=sort(M);
d=x(2:length(x))-x(1:length(x)-1); d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); eps=min(d(d>0));
if eps>0.1; eps=0.1;end if eps>0.1; eps=0.1;end
end end

View File

@@ -1,64 +1,64 @@
% [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax) % [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax)
% %
% EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE % EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE
% UNDER THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL. % UNDER THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R % Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distribution Mmax are calculated at % b-value and the end-point of the distribution Mmax are calculated at
% start-up of the stationary hazard assessment services in the % start-up of the stationary hazard assessment services in the
% upper-bounded Gutenberg-Richter estimation mode. % upper-bounded Gutenberg-Richter estimation mode.
% %
% The distribution function values are calculated for magnitude starting % The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM. % from Md up to Mu with step dM.
% %
%INPUT: %INPUT:
% Md - starting magnitude for distribution functions calculations % Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations % Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations % dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
%OUTPUT: %OUTPUT:
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu) % m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_GRT - PDF vector of the same length as m % PDF_GRT - PDF vector of the same length as m
% CDF_GRT - CDF vector of the same length as m % CDF_GRT - CDF vector of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax) function [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
beta=b*log(10); beta=b*log(10);
mian=(1-exp(-beta*(Mmax-Mmin+eps/2))); mian=(1-exp(-beta*(Mmax-Mmin+eps/2)));
PDF_GRT=beta*exp(-beta*(m-Mmin+eps/2))/mian; PDF_GRT=beta*exp(-beta*(m-Mmin+eps/2))/mian;
CDF_GRT=(1-exp(-beta*(m-Mmin+eps/2)))/mian; CDF_GRT=(1-exp(-beta*(m-Mmin+eps/2)))/mian;
idx=find(CDF_GRT<0); idx=find(CDF_GRT<0);
PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=zeros(size(idx)); PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=zeros(size(idx));
idx=find(CDF_GRT>1); idx=find(CDF_GRT>1);
PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=ones(size(idx)); PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=ones(size(idx));
end end

View File

@@ -1,61 +1,61 @@
% [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b) % [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b)
% %
% EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE % EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE
% UNDER THE UNLIMITED G-R LED MAGNITUDE DISTRIBUTION MODEL. % UNDER THE UNLIMITED G-R LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation % DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution % leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of % from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at % this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the % start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode. % unlimited Gutenberg-Richter estimation mode.
% %
% The distribution function values are calculated for magnitude starting % The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM. % from Md up to Mu with step dM.
% %
%INPUT: %INPUT:
% Md - starting magnitude for distribution functions calculations % Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations % Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations % dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% %
%OUTPUT: %OUTPUT:
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu) % m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_GRT - PDF vector of the same length as m % PDF_GRT - PDF vector of the same length as m
% CDF_GRT - CDF vector of the same length as m % CDF_GRT - CDF vector of the same length as m
% %
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b) function [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
beta=b*log(10); beta=b*log(10);
PDF_GRU=beta*exp(-beta*(m-Mmin+eps/2)); PDF_GRU=beta*exp(-beta*(m-Mmin+eps/2));
CDF_GRU=1-exp(-beta*(m-Mmin+eps/2)); CDF_GRU=1-exp(-beta*(m-Mmin+eps/2));
idx=find(CDF_GRU<0); idx=find(CDF_GRU<0);
PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=zeros(size(idx)); PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=zeros(size(idx));
idx=find(CDF_GRU>1); idx=find(CDF_GRU>1);
PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=ones(size(idx)); PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=ones(size(idx));
end end

View File

@@ -1,116 +1,116 @@
% [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax) % [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax)
% %
% USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY % USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY
% AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UPPER-BOUNDED MAGNITUDE % AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UPPER-BOUNDED MAGNITUDE
% DISTRIBUTION. % DISTRIBUTION.
% %
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand % the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters % side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off % namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the % interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of % scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the % magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with % randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2. % respect to the value Mmin-eps/2.
% %
% REFERENCES: % REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, % Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 % Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 % Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
%INPUT: %INPUT:
% Md - starting magnitude for distribution functions calculations % Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations % Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations % dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% m - vector of the independent variable (magnitude) % m - vector of the independent variable (magnitude)
% PDF_NPT - PDF vector % PDF_NPT - PDF vector
% CDF_NPT - CDF vector % CDF_NPT - CDF vector
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax) function [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
nn=length(m); nn=length(m);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
for i=1:nn for i=1:nn
if m(i)<Mmin-eps/2 if m(i)<Mmin-eps/2
PDF_NPT(i)=0;CDF_NPT(i)=0; PDF_NPT(i)=0;CDF_NPT(i)=0;
elseif m(i)>Mmax elseif m(i)>Mmax
PDF_NPT(i)=0;CDF_NPT(i)=1; PDF_NPT(i)=0;CDF_NPT(i)=1;
else else
PDF_NPT(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2)/mian; PDF_NPT(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2)/mian;
CDF_NPT(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian; CDF_NPT(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian;
end end
end end
PDF_NPT=PDF_NPT';CDF_NPT=CDF_NPT'; PDF_NPT=PDF_NPT';CDF_NPT=CDF_NPT';
end end
function [gau]=dens_npr1(y,x,ambd,h,x1) function [gau]=dens_npr1(y,x,ambd,h,x1)
%Nonparametric adaptive density for a variable from the interval [x1,inf) %Nonparametric adaptive density for a variable from the interval [x1,inf)
% x - the sample data doubled and sorted in the ascending order. Use % x - the sample data doubled and sorted in the ascending order. Use
% "podwajanie.m" first to accmoplish that. % "podwajanie.m" first to accmoplish that.
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
c=sqrt(2*pi); c=sqrt(2*pi);
if y<x1 if y<x1
gau=0; gau=0;
else else
gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h; gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h;
end end
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,114 +1,114 @@
% [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd) % [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd)
% %
% USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY % USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY
% AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UNLIMITED MAGNITUDE % AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UNLIMITED MAGNITUDE
% DISTRIBUTION. % DISTRIBUTION.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side. % the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel % The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the % estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample % scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled % - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2 % symmetrically with respect to the value Mmin-eps/2
% %
% The distribution function values are calculated for magnitude starting % The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM. % from Md up to Mu with step dM.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
%INPUT: %INPUT:
% Md - starting magnitude for distribution functions calculations % Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations % Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations % dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
% %
%OUTPUT %OUTPUT
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu) % m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_NPU - PDF vector of the same length as m % PDF_NPU - PDF vector of the same length as m
% CDF_NPU - CDF vector of the same length as m % CDF_NPU - CDF vector of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd) function [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
nn=length(m); nn=length(m);
for i=1:nn for i=1:nn
if m(i)>=Mmin-eps/2 if m(i)>=Mmin-eps/2
PDF_NPU(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2); PDF_NPU(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2);
CDF_NPU(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); CDF_NPU(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
else else
PDF_NPU(i)=0; PDF_NPU(i)=0;
CDF_NPU(i)=0; CDF_NPU(i)=0;
end end
end end
PDF_NPU=PDF_NPU';CDF_NPU=CDF_NPU'; PDF_NPU=PDF_NPU';CDF_NPU=CDF_NPU';
end end
function [gau]=dens_npr1(y,x,ambd,h,x1) function [gau]=dens_npr1(y,x,ambd,h,x1)
%Nonparametric adaptive density for a variable from the interval [x1,inf) %Nonparametric adaptive density for a variable from the interval [x1,inf)
% x - the sample data doubled and sorted in the ascending order. Use % x - the sample data doubled and sorted in the ascending order. Use
% "podwajanie.m" first to accmoplish that. % "podwajanie.m" first to accmoplish that.
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
c=sqrt(2*pi); c=sqrt(2*pi);
if y<x1 if y<x1
gau=0; gau=0;
else else
gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h; gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h;
end end
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,99 +1,99 @@
% [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax) % [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax)
% %
%EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UPPER-BOUNDED G-R %EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UPPER-BOUNDED G-R
% LED MAGNITUDE DISTRIBUTION MODEL. % LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R % Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the % b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the % activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded % stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode. % Gutenberg-Richter estimation mode.
% %
% The exceedance probability of magnitude M' in the time period of % The exceedance probability of magnitude M' in the time period of
% length T' is the probability of an earthquake of magnitude M' or greater % length T' is the probability of an earthquake of magnitude M' or greater
% to occur in T'. Depending on the value of the parameter opt the % to occur in T'. Depending on the value of the parameter opt the
% exceedance probability values are calculated for a fixed time period T' % exceedance probability values are calculated for a fixed time period T'
% and different magnitude values or for a fixed magnitude M' and different % and different magnitude values or for a fixed magnitude M' and different
% time period length values. In either case the independent variable vector % time period length values. In either case the independent variable vector
% starts from xd, up to xu with step dx. In either case the result is % starts from xd, up to xu with step dx. In either case the result is
% returned in the vector z. % returned in the vector z.
% %
%INPUT: %INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0, % y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1 % magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
%OUTPUT: %OUTPUT:
% x - vector of changeable independent variable: magnitudes if opt=0, % x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1, % time period lengths if opt=1,
% x=(xd:dx:xu) % x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x % z - vector of exceedance probability values of the same length as x
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax) function [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end if dx<=0;error('Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
beta=b*log(10); beta=b*log(10);
if opt==0 if opt==0
if xd<Mmin; xd=Mmin;end if xd<Mmin; xd=Mmin;end
if xu>Mmax; xu=Mmax;end if xu>Mmax; xu=Mmax;end
end end
x=(xd:dx:xu)'; x=(xd:dx:xu)';
if opt==0 if opt==0
z=1-exp(-lamb*y.*(1-Cdfgr(x,beta,Mmin-eps/2,Mmax))); z=1-exp(-lamb*y.*(1-Cdfgr(x,beta,Mmin-eps/2,Mmax)));
else else
z=1-exp(-lamb*(1-Cdfgr(y,beta,Mmin-eps/2,Mmax)).*x); z=1-exp(-lamb*(1-Cdfgr(y,beta,Mmin-eps/2,Mmax)).*x);
end end
end end
function [y]=Cdfgr(t,beta,Mmin,Mmax) function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R %CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model % model
% Mmin - catalog completeness level % Mmin - catalog completeness level
% Mmax - upper limit of the distribution % Mmax - upper limit of the distribution
% beta - the distribution parameter % beta - the distribution parameter
% t - vector of magnitudes (independent variable) % t - vector of magnitudes (independent variable)
% y - CDF vector % y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin))); mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian; y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1); idx=find(y>1);
y(idx)=ones(size(idx)); y(idx)=ones(size(idx));
end end

View File

@@ -1,78 +1,78 @@
% [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b) % [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b)
% %
%EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UNLIMITED G-R %EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UNLIMITED G-R
% LED MAGNITUDE DISTRIBUTION MODEL. % LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation % DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution % leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of % from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at % this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the % start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode. % unlimited Gutenberg-Richter estimation mode.
% %
% The exceedance probability of magnitude M' in the time period of % The exceedance probability of magnitude M' in the time period of
% length T' is the probability of an earthquake of magnitude M' or greater % length T' is the probability of an earthquake of magnitude M' or greater
% to occur in T'. Depending on the value of the parameter opt the % to occur in T'. Depending on the value of the parameter opt the
% exceedance probability values are calculated for a fixed time period T' % exceedance probability values are calculated for a fixed time period T'
% and different magnitude values or for a fixed magnitude M' and different % and different magnitude values or for a fixed magnitude M' and different
% time period length values. In either case the independent variable vector % time period length values. In either case the independent variable vector
% starts from xd, up to xu with step dx. In either case the result is % starts from xd, up to xu with step dx. In either case the result is
% returned in the vector z. % returned in the vector z.
% %
%INPUT: %INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0, % y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1 % magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
%OUTPUT %OUTPUT
% x - vector of changeable independent variable: magnitudes if opt=0, % x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1, % time period lengths if opt=1,
% x=(xd:dx:xu) % x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x % z - vector of exceedance probability values of the same length as x
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b) function [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end if dx<=0;error('Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
beta=b*log(10); beta=b*log(10);
if opt==0 if opt==0
if xd<Mmin; xd=Mmin;end if xd<Mmin; xd=Mmin;end
end end
x=(xd:dx:xu)'; x=(xd:dx:xu)';
if opt==0 if opt==0
z=1-exp(-lamb*y.*exp(-beta*(x-Mmin+eps/2))); z=1-exp(-lamb*y.*exp(-beta*(x-Mmin+eps/2)));
else else
z=1-exp(-lamb*exp(-beta*(y-Mmin+eps/2)).*x); z=1-exp(-lamb*exp(-beta*(y-Mmin+eps/2)).*x);
end end
end end

View File

@@ -1,116 +1,116 @@
% [x,z]=ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax) % [x,z]=ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE
% EXCEEDANCE PROBABILITY VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC % EXCEEDANCE PROBABILITY VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE. % DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand % the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters % side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off % namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the % interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of % scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the % magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with % randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2. % respect to the value Mmin-eps/2.
% %
% The exceedance probability of magnitude M' in the time % The exceedance probability of magnitude M' in the time
% period of length T' is the probability of an earthquake of magnitude M' % period of length T' is the probability of an earthquake of magnitude M'
% or greater to occur in T'. % or greater to occur in T'.
% %
% Depending on the value of the parameter opt the exceedance probability % Depending on the value of the parameter opt the exceedance probability
% values are calculated for a fixed time period T' and different magnitude % values are calculated for a fixed time period T' and different magnitude
% values or for a fixed magnitude M' and different time period length % values or for a fixed magnitude M' and different time period length
% values. In either case the independent variable vector starts from % values. In either case the independent variable vector starts from
% xd, up to xu with step dx. In either case the result is returned in the % xd, up to xu with step dx. In either case the result is returned in the
% vector z. % vector z.
% %
% REFERENCES: % REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, % Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 % Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 % Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% x - vector of changeable independent variable x=(xd:dx:xu) % x - vector of changeable independent variable x=(xd:dx:xu)
% z - vector of exceedance probability values % z - vector of exceedance probability values
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [x,z]=... function [x,z]=...
ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax) ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end if dx<=0;error('Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
if opt==0 if opt==0
if xd<Mmin; xd=Mmin;end if xd<Mmin; xd=Mmin;end
if xu>Mmax; xu=Mmax;end if xu>Mmax; xu=Mmax;end
end end
x=(xd:dx:xu)'; x=(xd:dx:xu)';
n=length(x); n=length(x);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
if opt==0 if opt==0
for i=1:n for i=1:n
CDF_NPT=2*(Dystr_npr(x(i),xx,ambd,h)... CDF_NPT=2*(Dystr_npr(x(i),xx,ambd,h)...
-Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian; -Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian;
z(i)=1-exp(-lamb*y.*(1-CDF_NPT)); z(i)=1-exp(-lamb*y.*(1-CDF_NPT));
end end
else else
CDF_NPT=2*(Dystr_npr(y,xx,ambd,h)... CDF_NPT=2*(Dystr_npr(y,xx,ambd,h)...
-Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian; -Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian;
z=1-exp(-lamb*(1-CDF_NPT).*x); z=1-exp(-lamb*(1-CDF_NPT).*x);
if y>Mmax;z=zeros(size(x));end %K15DEC2015 if y>Mmax;z=zeros(size(x));end %K15DEC2015
end end
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,105 +1,105 @@
% [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd) % [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE
% EXCEEDANCE PROBABILITY VALUES FOR THE UNBOUNDED NONPARAMETRIC % EXCEEDANCE PROBABILITY VALUES FOR THE UNBOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE. % DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side. % the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel % The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the % estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample % scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled % - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2. % symmetrically with respect to the value Mmin-eps/2.
% The exceedance probability of magnitude M' in the time period of length % The exceedance probability of magnitude M' in the time period of length
% T' is the probability of an earthquake of magnitude M' or greater to % T' is the probability of an earthquake of magnitude M' or greater to
% occur in T'. % occur in T'.
% Depending on the value of the parameter opt the exceedance probability % Depending on the value of the parameter opt the exceedance probability
% values are calculated for a fixed time period T' and different magnitude % values are calculated for a fixed time period T' and different magnitude
% values or for a fixed magnitude M' and different time period length % values or for a fixed magnitude M' and different time period length
% values. In either case the independent variable vector starts from % values. In either case the independent variable vector starts from
% xd, up to xu with step dx. In either case the result is returned in the % xd, up to xu with step dx. In either case the result is returned in the
% vector z. % vector z.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0, % y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1 % magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
% OUTPUT: % OUTPUT:
% x - vector of changeable independent variable: magnitudes if opt=0, % x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1, % time period lengths if opt=1,
% x=(xd:dx:xu) % x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x % z - vector of exceedance probability values of the same length as x
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd) function [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end if dx<=0;error('Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
x=(xd:dx:xu)'; x=(xd:dx:xu)';
n=length(x); n=length(x);
if opt==0 if opt==0
for i=1:n for i=1:n
CDF_NPU=2*(Dystr_npr(x(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); CDF_NPU=2*(Dystr_npr(x(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
z(i)=1-exp(-lamb*y.*(1-CDF_NPU)); z(i)=1-exp(-lamb*y.*(1-CDF_NPU));
end end
else else
CDF_NPU=2*(Dystr_npr(y,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); CDF_NPU=2*(Dystr_npr(y,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
z=1-exp(-lamb*(1-CDF_NPU).*x); z=1-exp(-lamb*(1-CDF_NPU).*x);
end end
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,59 +1,59 @@
% [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax) % [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax)
%EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UPPER-BOUNDED %EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UPPER-BOUNDED
% G-R LED MAGNITUDE DISTRIBUTION MODEL. % G-R LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R % Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the % b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the % activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded % stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode. % Gutenberg-Richter estimation mode.
% %
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
% INPUT: % INPUT:
% Td - starting period length for maximum credible magnitude calculations % Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations % Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations % dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax) function [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
beta=b*log(10); beta=b*log(10);
mian=(1-exp(-beta*(Mmax-Mmin+eps/2))); mian=(1-exp(-beta*(Mmax-Mmin+eps/2)));
m=Mmin-eps/2-1/beta*log((1-(1-1./(lamb*T))*mian)); m=Mmin-eps/2-1/beta*log((1-(1-1./(lamb*T))*mian));
end end

View File

@@ -1,63 +1,63 @@
% [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b) % [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b)
% %
%EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UNLIMITED %EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UNLIMITED
% G-R LED MAGNITUDE DISTRIBUTION MODEL. % G-R LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation % DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution % leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of % from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at % this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the % start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode. % unlimited Gutenberg-Richter estimation mode.
% %
% The maximum credible magnitude for the period of length T % The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T. % is the magnitude value whose mean return period is T.
% %
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
%INPUT: %INPUT:
% Td - starting period length for maximum credible magnitude calculations % Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations % Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations % dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% %
%OUTPUT: %OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b) function [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
beta=b*log(10); beta=b*log(10);
m=Mmin-eps/2+1/beta.*log(lamb*T); m=Mmin-eps/2+1/beta.*log(lamb*T);
end end

View File

@@ -1,98 +1,98 @@
% [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) % [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM
% CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC % CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE. % DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand % the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters % side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off % namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the % interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of % scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the % magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with % randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2. % respect to the value Mmin-eps/2.
% %
% The maximum credible magnitude for the period of length T % The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T. % is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
% REFERENCES: % REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, % Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 % Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 % Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% Td - starting period length for maximum credible magnitude calculations % Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations % Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations % dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) function [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
n=length(T); n=length(T);
interval=[Mmin-eps/2 Mmax-0.001]; interval=[Mmin-eps/2 Mmax-0.001];
for i=1:n for i=1:n
m(i)=fzero(@F_maxmagn,interval,[],xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i)); m(i)=fzero(@F_maxmagn,interval,[],xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i));
end end
m=m'; m=m';
end end
function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D) function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D)
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h)); mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian; CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian;
y=CDF_NPT-1+1/(lamb*D); y=CDF_NPT-1+1/(lamb*D);
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,98 +1,98 @@
% [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) ---- (Octave Compatible Version) % [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) ---- (Octave Compatible Version)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM
% CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC % CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE. % DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand % the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters % side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off % namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the % interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of % scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the % magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with % randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2. % respect to the value Mmin-eps/2.
% %
% The maximum credible magnitude for the period of length T % The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T. % is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
% REFERENCES: % REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, % Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 % Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 % Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% Td - starting period length for maximum credible magnitude calculations % Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations % Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations % dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) function [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
n=length(T); n=length(T);
interval=[Mmin-eps/2 Mmax-0.001]; interval=[Mmin-eps/2 Mmax-0.001];
for i=1:n for i=1:n
m(i)=fzero(@(t) F_maxmagn(t,xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i)),interval); m(i)=fzero(@(t) F_maxmagn(t,xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i)),interval);
end end
m=m'; m=m';
end end
function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D) function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D)
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h)); mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian; CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian;
y=CDF_NPT-1+1/(lamb*D); y=CDF_NPT-1+1/(lamb*D);
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,98 +1,98 @@
% [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) % [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED % THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE. % NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side. % the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel % The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the % estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample % scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled % - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2. % symmetrically with respect to the value Mmin-eps/2.
% %
% The maximum credible magnitude for the period of length T % The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T. % is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
%INPUT: %INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0, % y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1 % magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
%OUTPUT: %OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) function [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
n=length(T); n=length(T);
interval=[Mmin-eps/2 10.0]; interval=[Mmin-eps/2 10.0];
for i=1:n for i=1:n
m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i)); m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i));
end end
m=m'; m=m';
end end
function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D) function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D)
CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h)); CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
y=CDF_NPU-1+1/(lamb*D); y=CDF_NPU-1+1/(lamb*D);
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,99 +1,99 @@
% [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) ---- (Octave Comlatible Version) % [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) ---- (Octave Comlatible Version)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED % THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE. % NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side. % the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel % The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the % estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample % scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled % - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2. % symmetrically with respect to the value Mmin-eps/2.
% %
% The maximum credible magnitude for the period of length T % The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T. % is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of % The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT. % length starting from Td up to Tu with step dT.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
%INPUT: %INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period % opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude % length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x) % (y), different time period lengths (x)
% xd - starting value of the changeable independent variable % xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable % xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable % dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0, % y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1 % magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
%OUTPUT: %OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu) % T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T % m - vector of maximum credible magnitudes of the same length as T
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) function [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end if dT<=0;error('Time Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
T=(Td:dT:Tu)'; T=(Td:dT:Tu)';
n=length(T); n=length(T);
interval=[Mmin-eps/2 10.0]; interval=[Mmin-eps/2 10.0];
for i=1:n for i=1:n
% m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i)); % m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i));
m(i)=fzero(@(t) F_maxmagn_NPU(t,xx,h,ambd,Mmin-eps/2,lamb,T(i)),interval); m(i)=fzero(@(t) F_maxmagn_NPU(t,xx,h,ambd,Mmin-eps/2,lamb,T(i)),interval);
end end
m=m'; m=m';
end end
function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D) function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D)
CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h)); CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
y=CDF_NPU-1+1/(lamb*D); y=CDF_NPU-1+1/(lamb*D);
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,259 +1,259 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin) % [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin)
% %
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH % BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS % OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd % THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd
% FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE % FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE
% DISTRIBUTION. % DISTRIBUTION.
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !! % NON-PARAMETRIC HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor % to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian % h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel. % kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the % In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized % kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length - % within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the % eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done % least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0 % assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The % is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole % shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample % data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically % - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing % with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx. % factors row vector for the adaptive kernel is of the same size as xx.
% See: the references below for a more comprehensive description. % See: the references below for a more comprehensive description.
% %
% This is a beta version of the program. Further developments are foreseen. % This is a beta version of the program. Further developments are foreseen.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data) % M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% %
% OUTPUT % OUTPUT
% lamb_all - mean activity rate for all events % lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin % lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is % for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except % continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is % lamb_all and lamb are set to zero and the function execution is
% terminated. % terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of % ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (the zero of the h functional % the optimal smoothing factor has converged (the zero of the h functional
% has been found, ierr=1 when multiple zeros of h functional were % has been found, ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did % encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken. % not zeroe - the approximate h value is taken.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude % xx - the background sample for the nonparametric estimators of magnitude
% distribution % distribution
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=... function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=...
Nonpar(t,M,iop,Mmin) Nonpar(t,M,iop,Mmin)
lamb_err=0; lamb_err=0;
n=length(M); n=length(M);
t1=t(1); t1=t(1);
for i=1:n for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t1=t(i+1); t1=t(i+1);
end end
t2=t(n); t2=t(n);
for i=n:1 for i=n:1
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t2=t(i-1);
end end
nn=0; nn=0;
for i=1:n for i=1:n
if M(i)>=Mmin if M(i)>=Mmin
nn=nn+1; nn=nn+1;
end end
end end
if iop==0 if iop==0
lamb_all=n/round(t(n)-t(1)); lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1); lamb=nn/round(t2-t1);
unit='day'; unit='day';
elseif iop==1 elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014 lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014 lamb=30*nn/(t2-t1); % K20OCT2014
unit='month'; unit='month';
else else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014 lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014 lamb=365*nn/(t2-t1); % K20OCT2014
unit='year'; unit='year';
end end
if nn<50 if nn<50
eps=0;ierr=0;h=0; eps=0;ierr=0;h=0;
lamb_err=1; lamb_err=1;
return; return;
end end
eps=magn_accur(M); eps=magn_accur(M);
n=0; n=0;
for i=1:length(M) for i=1:length(M)
if M(i)>=Mmin; if M(i)>=Mmin;
n=n+1; n=n+1;
x(n)=M(i); x(n)=M(i);
end end
end end
x=sort(x)'; x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2); beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta); [xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx); xx=sort(xx);
clear x; clear x;
xx = podwajanie(xx,Mmin-eps/2); xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx); [h,ierr]=hopt(xx);
[ambd]=scaling(xx,h); [ambd]=scaling(xx,h);
end end
function [m_corr]=korekta(m,Mmin,eps,beta) function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL % RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
% %
% m - input vector of magnitudes % m - input vector of magnitudes
% Mmin - catalog completeness level % Mmin - catalog completeness level
% eps - accuracy of magnitude % eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution % beta - the parameter of the unbounded exponential distribution
% %
% m_corr - vector of randomized magnitudes % m_corr - vector of randomized magnitudes
% %
F1=1-exp(-beta*(m-Mmin-0.5*eps)); F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps)); F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m)); u=rand(size(m));
w=u.*(F2-F1)+F1; w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta; m_corr=Mmin-log(1-w)./beta;
end end
function x2 = podwajanie(x,x0) function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE % DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs % If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and % to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0] % belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)] % then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector % x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending % x2 - is the column vector of data doubled and sorted in the ascending
% order % order
x2=[-x+2*x0 x2=[-x+2*x0
x]; x];
x2=sort(x2); x2=sort(x2);
end end
function [h,ierr]=hopt(x) function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares %Estimation of the optimal smoothing factor by means of the least squares
%method %method
% x - column data vector % x - column data vector
% The result is an optimal smoothing factor % The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used % ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct' % The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros % NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search % search
% MODIFIED JUNE 2014 % MODIFIED JUNE 2014
ierr=0; ierr=0;
n=length(x); n=length(x);
x=sort(x); x=sort(x);
interval=[0.000001 2*std(x)/n^0.2]; interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
[hh(1),fval,exitflag]=fzero(@funct,interval,[],x); [hh(1),fval,exitflag]=fzero(@funct,interval,[],x);
% Extra zeros search % Extra zeros search
jj=1; jj=1;
for kk=2:7 for kk=2:7
interval(1)=1.1*hh(jj); interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj); interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
jj=jj+1; jj=jj+1;
[hh(jj),fval,exitflag]=fzero(@funct,interval,[],x); [hh(jj),fval,exitflag]=fzero(@funct,interval,[],x);
end end
end end
if jj>1;ierr=1;end if jj>1;ierr=1;end
h=max(hh); h=max(hh);
if exitflag==1;return;end if exitflag==1;return;end
end end
h=0.891836*(mean(x)-x(1))/(n^0.2); h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2; ierr=2;
end end
function [fct]=funct(t,x) function [fct]=funct(t,x)
p2=1.41421356; p2=1.41421356;
n=length(x); n=length(x);
yy=zeros(size(x)); yy=zeros(size(x));
for i=1:n, for i=1:n,
xij=(x-x(i)).^2/t^2; xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1); y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y); yy(i)=sum(y);
end; end;
fct=sum(yy)-2*n; fct=sum(yy)-2*n;
clear xij y yy; clear xij y yy;
end end
function [ambd]=scaling(x,h) function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE % EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION % ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending % x - the n dimensional column vector of data values sorted in the ascending
% order % order
% h - the optimal smoothing factor % h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors % ambd - the resultant n dimensional row vector of local scaling factors
n=length(x); n=length(x);
c=sqrt(2*pi); c=sqrt(2*pi);
gau=zeros(1,n); gau=zeros(1,n);
for i=1:n, for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h; gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end end
g=exp(mean(log(gau))); g=exp(mean(log(gau)));
ambd=sqrt(g./gau); ambd=sqrt(g./gau);
end end
function [eps]=magn_accur(M) function [eps]=magn_accur(M)
x=sort(M); x=sort(M);
d=x(2:length(x))-x(1:length(x)-1); d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); eps=min(d(d>0));
if eps>0.1; eps=0.1;end if eps>0.1; eps=0.1;end
end end

View File

@@ -1,310 +1,310 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin) % [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin)
% %
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH % BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS % OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd % THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd
% FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE % FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE
% DISTRIBUTION. % DISTRIBUTION.
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !! % NON-PARAMETRIC HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project. % AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor % to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian % h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel. % kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the % In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized % kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length - % within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the % eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done % least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0 % assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The % is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole % shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample % data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically % - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing % with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx. % factors row vector for the adaptive kernel is of the same size as xx.
% See: the references below for a more comprehensive description. % See: the references below for a more comprehensive description.
% %
% This is a beta version of the program. Further developments are foreseen. % This is a beta version of the program. Further developments are foreseen.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data) % M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% %
% OUTPUT % OUTPUT
% lamb_all - mean activity rate for all events % lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin % lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is % for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except % continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is % lamb_all and lamb are set to zero and the function execution is
% terminated. % terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of % ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (the zero of the h functional % the optimal smoothing factor has converged (the zero of the h functional
% has been found, ierr=1 when multiple zeros of h functional were % has been found, ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did % encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken. % not zeroe - the approximate h value is taken.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude % xx - the background sample for the nonparametric estimators of magnitude
% distribution % distribution
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=... function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=...
Nonpar_O(t,M,iop,Mmin) Nonpar_O(t,M,iop,Mmin)
if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP t=[1 2];M=[1 2]; end %K30SEP
lamb_err=0; lamb_err=0;
%%% %%%%%%%%%%%%%MICHAL %%% %%%%%%%%%%%%%MICHAL
xx=NaN; xx=NaN;
ambd=NaN; ambd=NaN;
%%% %%%%%%%%%%%%%MICHAL %%% %%%%%%%%%%%%%MICHAL
n=length(M); n=length(M);
t1=t(1); t1=t(1);
for i=1:n for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t1=t(i+1); t1=t(i+1);
end end
t2=t(n); t2=t(n);
for i=n:1 for i=n:1
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t2=t(i-1);
end end
nn=0; nn=0;
for i=1:n for i=1:n
if M(i)>=Mmin if M(i)>=Mmin
nn=nn+1; nn=nn+1;
end end
end end
% SL 03MAR2015 ---------------------------------- % SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop); [NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM; lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop); [NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM; lamb=nn/NM;
% SL 03MAR2015 ---------------------------------- % SL 03MAR2015 ----------------------------------
if nn<50 if nn<50
eps=0;ierr=0;h=0; eps=0;ierr=0;h=0;
lamb_err=1; lamb_err=1;
return; return;
end end
eps=magn_accur(M); eps=magn_accur(M);
n=0; n=0;
for i=1:length(M) for i=1:length(M)
if M(i)>=Mmin; if M(i)>=Mmin;
n=n+1; n=n+1;
x(n)=M(i); x(n)=M(i);
end end
end end
x=sort(x)'; x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2); beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta); [xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx); xx=sort(xx);
clear x; clear x;
xx = podwajanie(xx,Mmin-eps/2); xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx); [h,ierr]=hopt(xx);
[ambd]=scaling(xx,h); [ambd]=scaling(xx,h);
% enai=dlmread('para.txt'); %for fixed xx,ambd to test in different platforms % enai=dlmread('para.txt'); %for fixed xx,ambd to test in different platforms
% [ambd]=enai(:,1); % [ambd]=enai(:,1);
% xx=enai(:,2)'; % xx=enai(:,2)';
% [h,ierr]=hopt(xx); % [h,ierr]=hopt(xx);
end end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT % TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
% %
% t1 - start time (in MATLAB numerical format) % t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1 % t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% %
% NM - number of time units from t1 to t2 % NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0 if iop==0
NM=(t2-t1); NM=(t2-t1);
unit='day'; unit='day';
elseif iop==1 elseif iop==1
V1=datevec(t1); V1=datevec(t1);
V2=datevec(t2); V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))... NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12; +(V2(1)-V1(1)-1)*12;
unit='month'; unit='month';
else else
V1=datevec(t1); V1=datevec(t1);
V2=datevec(t2); V2=datevec(t2);
NM2=V2(3); NM2=V2(3);
if V2(2)>1 if V2(2)>1
for k=1:V2(2)-1 for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k); NM2=NM2+eomday(V2(1),k);
end end
end end
day2=365; if eomday(V2(1),2)==29; day2=366; end; day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2; NM2=NM2/day2;
NM1=V1(3); NM1=V1(3);
if V1(2)>1 if V1(2)>1
for k=1:V1(2)-1 for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k); NM1=NM1+eomday(V1(1),k);
end end
end end
day1=365; if eomday(V1(1),2)==29; day1=366; end; day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1; NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1; NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year'; unit='year';
end end
end end
function [m_corr]=korekta(m,Mmin,eps,beta) function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL % RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
% %
% m - input vector of magnitudes % m - input vector of magnitudes
% Mmin - catalog completeness level % Mmin - catalog completeness level
% eps - accuracy of magnitude % eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution % beta - the parameter of the unbounded exponential distribution
% %
% m_corr - vector of randomized magnitudes % m_corr - vector of randomized magnitudes
% %
F1=1-exp(-beta*(m-Mmin-0.5*eps)); F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps)); F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m)); u=rand(size(m));
w=u.*(F2-F1)+F1; w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta; m_corr=Mmin-log(1-w)./beta;
end end
function x2 = podwajanie(x,x0) function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE % DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs % If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and % to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0] % belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)] % then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector % x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending % x2 - is the column vector of data doubled and sorted in the ascending
% order % order
x2=[-x+2*x0 x2=[-x+2*x0
x]; x];
x2=sort(x2); x2=sort(x2);
end end
function [h,ierr]=hopt(x) function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares %Estimation of the optimal smoothing factor by means of the least squares
%method %method
% x - column data vector % x - column data vector
% The result is an optimal smoothing factor % The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used % ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct' % The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros % NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search % search
% MODIFIED JUNE 2014 % MODIFIED JUNE 2014
ierr=0; ierr=0;
n=length(x); n=length(x);
x=sort(x); x=sort(x);
interval=[0.000001 2*std(x)/n^0.2]; interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
fun = @(t) funct(t,x); % FOR OCTAVE fun = @(t) funct(t,x); % FOR OCTAVE
x0 =interval; % FOR OCTAVE x0 =interval; % FOR OCTAVE
[hh(1),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE [hh(1),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE
% Extra zeros search % Extra zeros search
jj=1; jj=1;
for kk=2:7 for kk=2:7
interval(1)=1.1*hh(jj); interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj); interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
jj=jj+1; jj=jj+1;
fun = @(t) funct(t,x); % FOR OCTAVE fun = @(t) funct(t,x); % FOR OCTAVE
x0 =interval; % FOR OCTAVE x0 =interval; % FOR OCTAVE
[hh(jj),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE [hh(jj),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE
end end
end end
if jj>1;ierr=1;end if jj>1;ierr=1;end
h=max(hh); h=max(hh);
if exitflag==1;return;end if exitflag==1;return;end
end end
h=0.891836*(mean(x)-x(1))/(n^0.2); h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2; ierr=2;
end end
function [fct]=funct(t,x) function [fct]=funct(t,x)
p2=1.41421356; p2=1.41421356;
n=length(x); n=length(x);
yy=zeros(size(x)); yy=zeros(size(x));
for i=1:n, for i=1:n,
xij=(x-x(i)).^2/t^2; xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1); y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y); yy(i)=sum(y);
end; end;
fct=sum(yy)-2*n; fct=sum(yy)-2*n;
clear xij y yy; clear xij y yy;
end end
function [ambd]=scaling(x,h) function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE % EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION % ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending % x - the n dimensional column vector of data values sorted in the ascending
% order % order
% h - the optimal smoothing factor % h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors % ambd - the resultant n dimensional row vector of local scaling factors
n=length(x); n=length(x);
c=sqrt(2*pi); c=sqrt(2*pi);
gau=zeros(1,n); gau=zeros(1,n);
for i=1:n, for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h; gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end end
g=exp(mean(log(gau))); g=exp(mean(log(gau)));
ambd=sqrt(g./gau); ambd=sqrt(g./gau);
end end
function [eps]=magn_accur(M) function [eps]=magn_accur(M)
x=sort(M); x=sort(M);
d=x(2:length(x))-x(1:length(x)-1); d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); eps=min(d(d>0));
if eps>0.1; eps=0.1;end if eps>0.1; eps=0.1;end
end end

View File

@@ -1,373 +1,373 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]= % [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=
% Nonpar(t,M,iop,Mmin) % Nonpar(t,M,iop,Mmin)
% %
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH % BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS % OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND % THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND
% THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC % THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC
% ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE % ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE
% ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION. % ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION.
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !! % NON-PARAMETRIC HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor % to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian % h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel. % kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the % In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized % kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length - % within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the % eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done % least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0 % assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The % is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole % shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample % data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically % - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing % with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx. % factors row vector for the adaptive kernel is of the same size as xx.
% The mean activity rate, lamb, is the number of events >=Mmin into the % The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. % length of the period in which they occurred.
% The upper limit of the distribution Mmax is evaluated using % The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the % the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used: % Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)). % Mmaxest= 2(max obs M) - (second max obs M)).
% %
% See: the references below for a more comprehensive description. % See: the references below for a more comprehensive description.
% %
% This is a beta version of the program. Further developments are foreseen. % This is a beta version of the program. Further developments are foreseen.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654 %Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673, %Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y % doi: 10.2478/s11600-010-0049-y
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data) % M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% %
% OUTPUT % OUTPUT
% lamb_all - mean activity rate for all events % lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin % lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is % for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except % continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is % lamb_all and lamb are set to zero and the function execution is
% terminated. % terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of % ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (a zero of the h functional % the optimal smoothing factor has converged (a zero of the h functional
% has been found), ierr=1 when multiple zeros of h functional were % has been found), ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did % encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken. % not zeroe - the approximate h value is taken.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude % xx - the background sample for the nonparametric estimators of magnitude
% distribution % distribution
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 - % err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock % no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used. % method used.
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=... function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=...
Nonpar_tr(t,M,iop,Mmin) Nonpar_tr(t,M,iop,Mmin)
lamb_err=0; lamb_err=0;
n=length(M); n=length(M);
t1=t(1); t1=t(1);
for i=1:n for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t1=t(i+1); t1=t(i+1);
end end
t2=t(n); t2=t(n);
for i=n:1 for i=n:1
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t2=t(i-1);
end end
nn=0; nn=0;
for i=1:n for i=1:n
if M(i)>=Mmin if M(i)>=Mmin
nn=nn+1; nn=nn+1;
end end
end end
if iop==0 if iop==0
lamb_all=n/round(t(n)-t(1)); lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1); lamb=nn/round(t2-t1);
unit='day'; unit='day';
elseif iop==1 elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014 lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014 lamb=30*nn/(t2-t1); % K20OCT2014
unit='month'; unit='month';
else else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014 lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014 lamb=365*nn/(t2-t1); % K20OCT2014
unit='year'; unit='year';
end end
if nn<50 if nn<50
eps=0;ierr=0;h=0;Mmax=0;err=0; eps=0;ierr=0;h=0;Mmax=0;err=0;
lamb_err=1; lamb_err=1;
return; return;
end end
eps=magn_accur(M); eps=magn_accur(M);
n=0; n=0;
for i=1:length(M) for i=1:length(M)
if M(i)>=Mmin; if M(i)>=Mmin;
n=n+1; n=n+1;
x(n)=M(i); x(n)=M(i);
end end
end end
x=sort(x)'; x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2); beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta); [xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx); xx=sort(xx);
clear x; clear x;
xx = podwajanie(xx,Mmin-eps/2); xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx); [h,ierr]=hopt(xx);
[ambd]=scaling(xx,h); [ambd]=scaling(xx,h);
[Mmax,err]=Mmaxest(xx,h,Mmin-eps/2); [Mmax,err]=Mmaxest(xx,h,Mmin-eps/2);
end end
function [m_corr]=korekta(m,Mmin,eps,beta) function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL % RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
% %
% m - input vector of magnitudes % m - input vector of magnitudes
% Mmin - catalog completeness level % Mmin - catalog completeness level
% eps - accuracy of magnitude % eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution % beta - the parameter of the unbounded exponential distribution
% %
% m_corr - vector of randomized magnitudes % m_corr - vector of randomized magnitudes
% %
F1=1-exp(-beta*(m-Mmin-0.5*eps)); F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps)); F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m)); u=rand(size(m));
w=u.*(F2-F1)+F1; w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta; m_corr=Mmin-log(1-w)./beta;
end end
function x2 = podwajanie(x,x0) function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE % DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs % If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and % to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0] % belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)] % then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector % x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending % x2 - is the column vector of data doubled and sorted in the ascending
% order % order
x2=[-x+2*x0 x2=[-x+2*x0
x]; x];
x2=sort(x2); x2=sort(x2);
end end
function [h,ierr]=hopt(x) function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares %Estimation of the optimal smoothing factor by means of the least squares
%method %method
% x - column data vector % x - column data vector
% The result is an optimal smoothing factor % The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used % ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct' % The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros % NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search % search
% MODIFIED JUNE 2014 % MODIFIED JUNE 2014
ierr=0; ierr=0;
n=length(x); n=length(x);
x=sort(x); x=sort(x);
interval=[0.000001 2*std(x)/n^0.2]; interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
[hh(1),fval,exitflag]=fzero(@funct,interval,[],x); [hh(1),fval,exitflag]=fzero(@funct,interval,[],x);
% Extra zeros search % Extra zeros search
jj=1; jj=1;
for kk=2:7 for kk=2:7
interval(1)=1.1*hh(jj); interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj); interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x); x1=funct(interval(1),x);
x2=funct(interval(2),x); x2=funct(interval(2),x);
if x1*x2<0 if x1*x2<0
jj=jj+1; jj=jj+1;
[hh(jj),fval,exitflag]=fzero(@funct,interval,[],x); [hh(jj),fval,exitflag]=fzero(@funct,interval,[],x);
end end
end end
if jj>1;ierr=1;end if jj>1;ierr=1;end
h=max(hh); h=max(hh);
if exitflag==1;return;end if exitflag==1;return;end
end end
h=0.891836*(mean(x)-x(1))/(n^0.2); h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2; ierr=2;
end end
function [fct]=funct(t,x) function [fct]=funct(t,x)
p2=1.41421356; p2=1.41421356;
n=length(x); n=length(x);
yy=zeros(size(x)); yy=zeros(size(x));
for i=1:n, for i=1:n,
xij=(x-x(i)).^2/t^2; xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1); y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y); yy(i)=sum(y);
end; end;
fct=sum(yy)-2*n; fct=sum(yy)-2*n;
clear xij y yy; clear xij y yy;
end end
function [ambd]=scaling(x,h) function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE % EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION % ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending % x - the n dimensional column vector of data values sorted in the ascending
% order % order
% h - the optimal smoothing factor % h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors % ambd - the resultant n dimensional row vector of local scaling factors
n=length(x); n=length(x);
c=sqrt(2*pi); c=sqrt(2*pi);
gau=zeros(1,n); gau=zeros(1,n);
for i=1:n, for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h; gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end end
g=exp(mean(log(gau))); g=exp(mean(log(gau)));
ambd=sqrt(g./gau); ambd=sqrt(g./gau);
end end
function [eps]=magn_accur(M) function [eps]=magn_accur(M)
x=sort(M); x=sort(M);
d=x(2:length(x))-x(1:length(x)-1); d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); eps=min(d(d>0));
if eps>0.1; eps=0.1;end if eps>0.1; eps=0.1;end
end end
function [Mmax,ierr]=Mmaxest(x,h,Mmin) function [Mmax,ierr]=Mmaxest(x,h,Mmin)
% ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS % ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS
% x - row vector of magnitudes (basic sample). % x - row vector of magnitudes (basic sample).
% h - optimal smoothing factor % h - optimal smoothing factor
% Mmax - upper bound % Mmax - upper bound
% ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas % ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas
% estimation % estimation
% Uses function 'dystryb' % Uses function 'dystryb'
n=length(x); n=length(x);
ierr=1; ierr=1;
x=sort(x); x=sort(x);
Mmax1=x(n); Mmax1=x(n);
for i=1:50, for i=1:50,
d=normcdf((Mmin-x)./h); d=normcdf((Mmin-x)./h);
mian=sum(normcdf((Mmax1-x)./h)-d); mian=sum(normcdf((Mmax1-x)./h)-d);
Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d); Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d);
if abs(Mmax-Mmax1)<0.01 if abs(Mmax-Mmax1)<0.01
ierr=0;break; ierr=0;break;
end end
Mmax1=Mmax; Mmax1=Mmax;
end end
if (ierr==1 || Mmax>9) if (ierr==1 || Mmax>9)
Mmax=2*x(n)-x(n-1); Mmax=2*x(n)-x(n-1);
ierr=1; ierr=1;
end end
end end
function [y]=dystryb(z,h,mian,x,d) function [y]=dystryb(z,h,mian,x,d)
n=length(x); n=length(x);
m=length(z); m=length(z);
for i=1:m, for i=1:m,
t=(z(i)-x)./h; t=(z(i)-x)./h;
t=normcdf(t); t=normcdf(t);
yy=sum(t-d); yy=sum(t-d);
y(i)=(yy/mian)^n; y(i)=(yy/mian)^n;
end end
end end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin) function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY % Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated % funfc - string with the name of function to be integrated
% a,b - integration limits % a,b - integration limits
% eps - accurracy % eps - accurracy
% varargin - other parameters of function to be integrated % varargin - other parameters of function to be integrated
% calka - integral % calka - integral
% ier=0 - convergence, ier=1 - no conbergence % ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ... W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ... 0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ... 0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069]; 0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ... X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ... 0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ... 0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637]; 0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12; CONST=1E-12;
delta=CONST*abs(a-b); delta=CONST*abs(a-b);
calka=0.; calka=0.;
aa=a; aa=a;
y=b-aa; y=b-aa;
ier=0; ier=0;
while abs(y)>delta, while abs(y)>delta,
bb=aa+y; bb=aa+y;
c1=0.5*(aa+bb); c1=0.5*(aa+bb);
c2=c1-aa; c2=c1-aa;
s8=0.; s8=0.;
s16=0.; s16=0.;
for i=1:4, for i=1:4,
u=X(i)*c2; u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end end
for i=5:12, for i=5:12,
u=X(i)*c2; u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end end
s8=s8*c2; s8=s8*c2;
s16=s16*c2; s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16)) if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y; y=0.5*y;
calka=0.; calka=0.;
ier=1; ier=1;
else else
calka=calka+s16; calka=calka+s16;
aa=bb; aa=bb;
y=b-aa; y=b-aa;
ier=0; ier=0;
end end
end end
end end

View File

@@ -1,431 +1,506 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]= % [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err,BIAS,SD]=
% Nonpar_tr(t,M,iop,Mmin) % Nonpar_tr(t,M,iop,Mmin,Mmax,Nsynth)
% %
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH % BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS % OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND % THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND
% THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC % THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC
% ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE % ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE
% ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION. % ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION.
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !! % NON-PARAMETRIC HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project. % AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor % to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian % h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel. % kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the % In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized % kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length - % within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the % eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done % least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0 % assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The % is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole % shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample % data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically % - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing % with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx. % factors row vector for the adaptive kernel is of the same size as xx.
% The mean activity rate, lamb, is the number of events >=Mmin into the % The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. % length of the period in which they occurred.
% The upper limit of the distribution Mmax is evaluated using % The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the % the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used: % Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)). % Mmaxest= 2(max obs M) - (second max obs M)).
% %
% See: the references below for a more comprehensive description. % See: the references below for a more comprehensive description.
% %
% This is a beta version of the program. Further developments are foreseen. % This is a beta version of the program. Further developments are foreseen.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654 %Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673, %Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y % doi: 10.2478/s11600-010-0049-y
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data) % M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% % Mmax - upper limit of Magnitude Distribution. Can be set by user, or
% OUTPUT % estimate within the program - it then should be set as Mmax=[].
% lamb_all - mean activity rate for all events %
% lamb - mean activity rate for events >= Mmin % OUTPUT
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_all - mean activity rate for all events
% for 50 or more events >=Mmin and the parameter estimation is % lamb - mean activity rate for events >= Mmin
% continued, lamb_err=1 otherwise, all output paramters except % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% lamb_all and lamb are set to zero and the function execution is % for 50 or more events >=Mmin and the parameter estimation is
% terminated. % continued, lamb_err=1 otherwise, all output paramters except
% unit - string with name of time unit used ('year' or 'month' or 'day'). % lamb_all and lamb are set to zero and the function execution is
% eps - length of round-off interval of magnitudes. % terminated.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of % unit - string with name of time unit used ('year' or 'month' or 'day').
% the optimal smoothing factor has converged (a zero of the h functional % eps - length of round-off interval of magnitudes.
% has been found), ierr=1 when multiple zeros of h functional were % ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% encountered - the largest h is accepted, ierr = 2 when h functional did % the optimal smoothing factor has converged (a zero of the h functional
% not zeroe - the approximate h value is taken. % has been found), ierr=1 when multiple zeros of h functional were
% h - kernel smoothing factor. % encountered - the largest h is accepted, ierr = 2 when h functional did
% xx - the background sample for the nonparametric estimators of magnitude % not zeroe - the approximate h value is taken.
% distribution % h - kernel smoothing factor.
% ambd - the weigthing factors for the adaptive kernel % xx - the background sample for the nonparametric estimators of magnitude
% Mmax - upper limit of magnitude distribution % distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 - % ambd - the weigthing factors for the adaptive kernel
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock % Mmax - upper limit of magnitude distribution
% method used. % err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% % no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% LICENSE % method used.
% This file is a part of the IS-EPOS e-PLATFORM. % BIAS - Mmax estimation Bias (Lasocki and Urban, 2011)
% % SD - Mmax standard deviation (Lasocki ands Urban, 2011)
% This is free software: you can redistribute it and/or modify it under %
% the terms of the GNU General Public License as published by the Free % LICENSE
% Software Foundation, either version 3 of the License, or % This file is a part of the IS-EPOS e-PLATFORM.
% (at your option) any later version. %
% % This is free software: you can redistribute it and/or modify it under
% This program is distributed in the hope that it will be useful, % the terms of the GNU General Public License as published by the Free
% but WITHOUT ANY WARRANTY; without even the implied warranty of % Software Foundation, either version 3 of the License, or
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % (at your option) any later version.
% GNU General Public License for more details. %
% % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=... % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Nonpar_tr_O(t,M,iop,Mmin,Mmax) % GNU General Public License for more details.
%
if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err,BIAS,SD]=...
Nonpar_tr_Ob(t,M,iop,Mmin,Mmax,Nsynth)
lamb_err=0; if nargin==5;Nsynth=[];end % K08DEC2019
n=length(M); if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT
t1=t(1); t=[1 2];M=[1 2]; end %K30SEP
%%% %%%%%%%%%%%%%MICHAL
xx=NaN; lamb_err=0;
ambd=NaN; n=length(M);
%%% %%%%%%%%%%%%%MICHAL t1=t(1);
for i=1:n %%% %%%%%%%%%%%%%MICHAL
if M(i)>=Mmin; break; end xx=NaN;
t1=t(i+1); ambd=NaN;
end %%% %%%%%%%%%%%%%MICHAL
t2=t(n); for i=1:n
for i=n:1 if M(i)>=Mmin; break; end
if M(i)>=Mmin; break; end t1=t(i+1);
t2=t(i-1); end
end t2=t(n);
nn=0; for i=n:1
for i=1:n if M(i)>=Mmin; break; end
if M(i)>=Mmin t2=t(i-1);
nn=nn+1; end
end nn=0;
end for i=1:n
% SL 03MAR2015 ---------------------------------- if M(i)>=Mmin
[NM,unit]=time_diff(t(1),t(n),iop); nn=nn+1;
lamb_all=n/NM; end
[NM,unit]=time_diff(t1,t2,iop); end
lamb=nn/NM; % SL 03MAR2015 ----------------------------------
% SL 03MAR2015 ---------------------------------- [NM,unit]=time_diff(t(1),t(n),iop);
if nn<50 lamb_all=n/NM;
eps=0;ierr=0;h=0;Mmax=0;err=0; [NM,unit]=time_diff(t1,t2,iop);
lamb_err=1; lamb=nn/NM;
return; % SL 03MAR2015 ----------------------------------
end if nn<50
eps=0;ierr=0;h=0;Mmax=0;err=0;
eps=magn_accur(M); lamb_err=1;
n=0; BIAS=NaN;SD=NaN; %%% K 08NOV2019
for i=1:length(M) return;
if M(i)>=Mmin; end
n=n+1;
x(n)=M(i); eps=magn_accur(M);
end n=0;
end for i=1:length(M)
x=sort(x)'; if M(i)>=Mmin;
beta=1/(mean(x)-Mmin+eps/2); n=n+1;
[xx]=korekta(x,Mmin,eps,beta); x(n)=M(i);
xx=sort(xx); end
clear x; end
xx = podwajanie(xx,Mmin-eps/2); x=sort(x)';
[h,ierr]=hopt(xx); beta=1/(mean(x)-Mmin+eps/2);
[ambd]=scaling(xx,h); [xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx);
if isempty(Mmax) %K30AUG2019 - Allow for manually set Mmax clear x;
[Mmax,err]=Mmaxest(xx,h,Mmin-eps/2); xx = podwajanie(xx,Mmin-eps/2);
else [h,ierr]=hopt(xx);
err=0; %K30AUG2019 [ambd]=scaling(xx,h);
end
% enai=dlmread('paraT.txt'); %for fixed xx,ambd to test in different platforms if isempty(Mmax) %K30AUG2019 - Allow for manually set Mmax
% [ambd]=enai(:,1); err_Mmax=1;[Mmax,err]=Mmaxest(xx,h,Mmin-eps/2); % err_Mmax added 04DEC2019
% xx=enai(:,2)'; else
% [h,ierr]=hopt(xx); err_Mmax=0;err=0; %K30AUG2019
% [Mmax,err]=Mmaxest(xx,h,Mmin-eps/2); end
end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 ---------------------------------- % Estimation of Mmax Bias %%% K 04DEC2019
% (Lasocki and Urban, 2011, doi:10.2478/s11600-010-0049-y)
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT if isempty(Nsynth)==0 && err_Mmax==1 % set number of synthetic datasets, e.g. 10000
% [BIAS,SD]=Mmax_Bias_GR(t,M,Mmin,Mmax,err,h,xx,ambd,Nsynth);
% t1 - start time (in MATLAB numerical format) elseif isempty(Nsynth)==0 && err_Mmax==0;
% t2 - end time (in MATLAB numerical format) t2>=t1 warning('Mmax must be empty for BIAS calculation');BIAS=[];SD=[];
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', else; BIAS=0;SD=0;
% iop=2 - 'year' end
%
% NM - number of time units from t1 to t2 end
% unit - string with name of time unit used ('year' or 'month' or 'day').
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 ----------------------------------
if iop==0
NM=(t2-t1); % TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
unit='day'; %
elseif iop==1 % t1 - start time (in MATLAB numerical format)
V1=datevec(t1); % t2 - end time (in MATLAB numerical format) t2>=t1
V2=datevec(t2); % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))... % iop=2 - 'year'
+(V2(1)-V1(1)-1)*12; %
unit='month'; % NM - number of time units from t1 to t2
else % unit - string with name of time unit used ('year' or 'month' or 'day').
V1=datevec(t1);
V2=datevec(t2); if iop==0
NM2=V2(3); NM=(t2-t1);
if V2(2)>1 unit='day';
for k=1:V2(2)-1 elseif iop==1
NM2=NM2+eomday(V2(1),k); V1=datevec(t1);
end V2=datevec(t2);
end NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
day2=365; if eomday(V2(1),2)==29; day2=366; end; +(V2(1)-V1(1)-1)*12;
NM2=NM2/day2; unit='month';
NM1=V1(3); else
if V1(2)>1 V1=datevec(t1);
for k=1:V1(2)-1 V2=datevec(t2);
NM1=NM1+eomday(V1(1),k); NM2=V2(3);
end if V2(2)>1
end for k=1:V2(2)-1
day1=365; if eomday(V1(1),2)==29; day1=366; end; NM2=NM2+eomday(V2(1),k);
NM1=(day1-NM1)/day1; end
NM=NM2+NM1+V2(1)-V1(1)-1; end
unit='year'; day2=365; if eomday(V2(1),2)==29; day2=366; end;
end NM2=NM2/day2;
end NM1=V1(3);
if V1(2)>1
function [m_corr]=korekta(m,Mmin,eps,beta) for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k);
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL end
% end
% m - input vector of magnitudes day1=365; if eomday(V1(1),2)==29; day1=366; end;
% Mmin - catalog completeness level NM1=(day1-NM1)/day1;
% eps - accuracy of magnitude NM=NM2+NM1+V2(1)-V1(1)-1;
% beta - the parameter of the unbounded exponential distribution unit='year';
% end
% m_corr - vector of randomized magnitudes end
%
F1=1-exp(-beta*(m-Mmin-0.5*eps)); function [m_corr]=korekta(m,Mmin,eps,beta)
F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m)); % RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
w=u.*(F2-F1)+F1; %
m_corr=Mmin-log(1-w)./beta; % m - input vector of magnitudes
end % Mmin - catalog completeness level
% eps - accuracy of magnitude
function x2 = podwajanie(x,x0) % beta - the parameter of the unbounded exponential distribution
%
% DOUBLES THE SAMPLE % m_corr - vector of randomized magnitudes
%
% If the sample x(i) is is truncated from the left hand side and belongs F1=1-exp(-beta*(m-Mmin-0.5*eps));
% to the interval [x0,inf) or it is truncated from the right hand side and F2=1-exp(-beta*(m-Mmin+0.5*eps));
% belongs to the interval (-inf,x0] u=rand(size(m));
% then the doubled sample is [-x(i)+2x0,x(i)] w=u.*(F2-F1)+F1;
% x - is the column data vector m_corr=Mmin-log(1-w)./beta;
% x2 - is the column vector of data doubled and sorted in the ascending end
% order
function x2 = podwajanie(x,x0)
x2=[-x+2*x0
x]; % DOUBLES THE SAMPLE
x2=sort(x2);
end % If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and
function [h,ierr]=hopt(x) % belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)]
%Estimation of the optimal smoothing factor by means of the least squares % x - is the column data vector
%method % x2 - is the column vector of data doubled and sorted in the ascending
% x - column data vector % order
% The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used x2=[-x+2*x0
% The function calls the procedure FZERO for the function 'funct' x];
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros x2=sort(x2);
% search end
% MODIFIED JUNE 2014 function [h,ierr]=hopt(x)
ierr=0; %Estimation of the optimal smoothing factor by means of the least squares
n=length(x); %method
x=sort(x); % x - column data vector
interval=[0.000001 2*std(x)/n^0.2]; % The result is an optimal smoothing factor
x1=funct(interval(1),x); % ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
x2=funct(interval(2),x); % The function calls the procedure FZERO for the function 'funct'
if x1*x2<0 % NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
fun = @(t) funct(t,x); % for octave % search
x0 =interval; % for octave
[hh(1),fval,exitflag] = fzero(fun,x0); % for octave % MODIFIED JUNE 2014
% Extra zeros search ierr=0;
jj=1; n=length(x);
for kk=2:7 x=sort(x);
interval(1)=1.1*hh(jj); interval=[0.000001 2*std(x)/n^0.2];
interval(2)=interval(1)+(kk-1)*hh(jj); x1=funct(interval(1),x);
x1=funct(interval(1),x); x2=funct(interval(2),x);
x2=funct(interval(2),x); if x1*x2<0
if x1*x2<0 fun = @(t) funct(t,x); % for octave
jj=jj+1; x0 =interval; % for octave
fun = @(t) funct(t,x); % for octave [hh(1),fval,exitflag] = fzero(fun,x0); % for octave
x0 =interval; % for octave
[hh(jj),fval,exitflag] = fzero(fun,x0); % for octave % Extra zeros search
end jj=1;
end for kk=2:7
if jj>1;ierr=1;end interval(1)=1.1*hh(jj);
h=max(hh); interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x);
if exitflag==1;return;end x2=funct(interval(2),x);
if x1*x2<0
end jj=jj+1;
h=0.891836*(mean(x)-x(1))/(n^0.2); fun = @(t) funct(t,x); % for octave
ierr=2; x0 =interval; % for octave
end [hh(jj),fval,exitflag] = fzero(fun,x0); % for octave
end
function [fct]=funct(t,x) end
p2=1.41421356; if jj>1;ierr=1;end
n=length(x); h=max(hh);
yy=zeros(size(x));
for i=1:n, if exitflag==1;return;end
xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1); end
yy(i)=sum(y); h=0.891836*(mean(x)-x(1))/(n^0.2);
end; ierr=2;
fct=sum(yy)-2*n; end
clear xij y yy;
end function [fct]=funct(t,x)
p2=1.41421356;
n=length(x);
function [ambd]=scaling(x,h) yy=zeros(size(x));
for i=1:n,
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE xij=(x-x(i)).^2/t^2;
% ESTIMATION y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y);
% x - the n dimensional column vector of data values sorted in the ascending end;
% order fct=sum(yy)-2*n;
% h - the optimal smoothing factor clear xij y yy;
% ambd - the resultant n dimensional row vector of local scaling factors end
n=length(x);
c=sqrt(2*pi); function [ambd]=scaling(x,h)
gau=zeros(1,n);
for i=1:n, % EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h; % ESTIMATION
end
g=exp(mean(log(gau))); % x - the n dimensional column vector of data values sorted in the ascending
ambd=sqrt(g./gau); % order
end % h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors
function [eps]=magn_accur(M)
x=sort(M); n=length(x);
d=x(2:length(x))-x(1:length(x)-1); c=sqrt(2*pi);
eps=min(d(d>0)); gau=zeros(1,n);
if eps>0.1; eps=0.1;end for i=1:n,
end gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end
function [Mmax,ierr]=Mmaxest(x,h,Mmin) g=exp(mean(log(gau)));
ambd=sqrt(g./gau);
% ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS end
% x - row vector of magnitudes (basic sample).
% h - optimal smoothing factor function [eps]=magn_accur(M)
% Mmax - upper bound x=sort(M);
% ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas d=x(2:length(x))-x(1:length(x)-1);
% estimation eps=min(d(d>0));
if eps>0.1; eps=0.1;end
% Uses function 'dystryb' end
n=length(x); function [Mmax,ierr]=Mmaxest(x,h,Mmin)
ierr=1;
x=sort(x); % ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS
Mmax1=x(n); % x - row vector of magnitudes (basic sample).
for i=1:50, % h - optimal smoothing factor
d=normcdf((Mmin-x)./h); % Mmax - upper bound
mian=sum(normcdf((Mmax1-x)./h)-d); % ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas
Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d); % estimation
if abs(Mmax-Mmax1)<0.01
ierr=0;break; % Uses function 'dystryb'
end
Mmax1=Mmax; n=length(x);
end ierr=1;
if (ierr==1 || Mmax>9) x=sort(x);
Mmax=2*x(n)-x(n-1); Mmax1=x(n);
ierr=1; for i=1:50,
end d=normcdf((Mmin-x)./h);
end mian=sum(normcdf((Mmax1-x)./h)-d);
Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d);
function [y]=dystryb(z,h,mian,x,d) if abs(Mmax-Mmax1)<0.01
n=length(x); ierr=0;break;
m=length(z); end
for i=1:m, Mmax1=Mmax;
t=(z(i)-x)./h; end
t=normcdf(t); if (ierr==1 || Mmax>9)
yy=sum(t-d); Mmax=2*x(n)-x(n-1);
y(i)=(yy/mian)^n; ierr=1;
end end
end end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin) function [y]=dystryb(z,h,mian,x,d)
n=length(x);
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY m=length(z);
for i=1:m,
% funfc - string with the name of function to be integrated t=(z(i)-x)./h;
% a,b - integration limits t=normcdf(t);
% eps - accurracy yy=sum(t-d);
% varargin - other parameters of function to be integrated y(i)=(yy/mian)^n;
% calka - integral end
% ier=0 - convergence, ier=1 - no conbergence end
persistent W X CONST function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ... % Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069]; % funfc - string with the name of function to be integrated
X=[0.960289856497536 0.796666477413627 0.525532409916329 ... % a,b - integration limits
0.183434642495650 0.989400934991650 0.944575023073233 ... % eps - accurracy
0.865631202387832 0.755404408355003 0.617876244402644 ... % varargin - other parameters of function to be integrated
0.458016777657227 0.281603550779259 0.095012509837637]; % calka - integral
CONST=1E-12; % ier=0 - convergence, ier=1 - no conbergence
delta=CONST*abs(a-b);
calka=0.; persistent W X CONST
aa=a; W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
y=b-aa; 0.362683783378362 0.027152459411754 0.062253523938648 ...
ier=0; 0.095158511682493 0.124628971255534 0.149595988816577 ...
while abs(y)>delta, 0.169156519395003 0.182603415044924 0.189450610455069];
bb=aa+y; X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
c1=0.5*(aa+bb); 0.183434642495650 0.989400934991650 0.944575023073233 ...
c2=c1-aa; 0.865631202387832 0.755404408355003 0.617876244402644 ...
s8=0.; 0.458016777657227 0.281603550779259 0.095012509837637];
s16=0.; CONST=1E-12;
for i=1:4, delta=CONST*abs(a-b);
u=X(i)*c2; calka=0.;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); aa=a;
end y=b-aa;
for i=5:12, ier=0;
u=X(i)*c2; while abs(y)>delta,
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); bb=aa+y;
end c1=0.5*(aa+bb);
s8=s8*c2; c2=c1-aa;
s16=s16*c2; s8=0.;
if abs(s16-s8)>eps*(1+abs(s16)) s16=0.;
y=0.5*y; for i=1:4,
calka=0.; u=X(i)*c2;
ier=1; s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
else end
calka=calka+s16; for i=5:12,
aa=bb; u=X(i)*c2;
y=b-aa; s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
ier=0; end
end s8=s8*c2;
end s16=s16*c2;
end if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y;
calka=0.;
ier=1;
else
calka=calka+s16;
aa=bb;
y=b-aa;
ier=0;
end
end
end
% --------------------- Mmax BIAS estimation routine ---------------------- K 08NOV2019
function [BIAS,SD]=Mmax_Bias_GR(t,m,Mc,Mmax1,err,h,xx,ambd,synth)
s1=sort(unique(m));s2=s1(2:length(s1))-s1(1:length(s1)-1);EPS=min(s2);
if err~=0
warning('process did not converge!!')
end
MAXm=max(m);N=numel(m(m>=Mc));DeltaM=MAXm-Mc; %beta=b*log(10);
[mag,PDF_NPT,CDF_NPT]=dist_NPT(Mc-EPS,Mmax1+EPS,0.01,Mc,EPS,h,xx,ambd,Mmax1);
for j=1:synth %set number of synthetic datasets, default is 10000
% % CDF:
% j
% linear interpolation to assign magnitude values from a uniform distribution sample
iM=rand(1,N);M1=interp1q(CDF_NPT,mag,iM');
br(j)=1/(log(10)*(mean(M1)-min(M1)+EPS/2));DM=range(M1);
Mmax=max(M1);
% Iteration Process to estimate b and Mmax
b1=10;best=[1.0 10.0];i=1;
while min(abs(diff(best)))>0.00001
w=exp(b1*(Mmax-Mc));E1=expint(N/(w-1));E2=expint(N*w/(w-1));
%E=expint(w);
Mme=Mmax+(E1-E2)/(b1*exp(-N/(w-1)))+(Mc)*exp(-N); %Mme=round(Mme/EPS)*EPS;
if isnan(Mme)
KM=sort(unique(M1),'descend');
Mme=2*KM(1)-KM(2);
end
fun=@(bb) 1/bb+(Mme-Mc)/(1-exp(bb*(Mme-Mc)))-mean(M1)+Mc-EPS/2; %consider th5 last 0.05 term
b1=fzero(fun,1);best(i)=b1;i=i+1;
if i==50
warning('process did not converge!!');break
end
end
be(j)=b1/log(10);
Me(j)=Mme;dm(j)=DM;Mm(j)=Mmax;
end
BIAS=mean(MAXm-Me);
SD=std(MAXm-Me);
%b-mean(be) %check b-value difference
%histogram(be)
% MAXm: maximum magnitude in the real catalog
% Mmax: maximum magnitudes observed in the synthetic catalogs (rounded)
% Me: maximum magnitude estimates for the synthetic catalogs
% Mmax1: maximum magnitude estimated by GRT
end

View File

@@ -1,83 +1,83 @@
% [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax) % [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax)
% %
% EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UPPER-BOUNDED G-R LED % EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UPPER-BOUNDED G-R LED
% MAGNITUDE DISTRIBUTION MODEL. % MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R % Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the % b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the % activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded % stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode. % Gutenberg-Richter estimation mode.
% %
% The mean return period of magnitude M is the average elapsed time between % The mean return period of magnitude M is the average elapsed time between
% the consecutive earthquakes of magnitude M. % the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up % The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM. % to Mu with step dM.
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes % M - vector of earthquake magnitudes
% Md - starting magnitude for return period calculations % Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations % Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations % dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% OUTPUT: % OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu) % m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m % T - vector od mean return periods of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax) function [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
if Md<Mmin; Md=Mmin;end if Md<Mmin; Md=Mmin;end
if Mu>Mmax; Mu=Mmax;end if Mu>Mmax; Mu=Mmax;end
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
beta=b*log(10); beta=b*log(10);
T=1/lamb./(1-Cdfgr(m,beta,Mmin-eps/2,Mmax)); T=1/lamb./(1-Cdfgr(m,beta,Mmin-eps/2,Mmax));
end end
function [y]=Cdfgr(t,beta,Mmin,Mmax) function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R %CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model % model
% Mmin - catalog completeness level % Mmin - catalog completeness level
% Mmax - upper limit of the distribution % Mmax - upper limit of the distribution
% beta - the distribution parameter % beta - the distribution parameter
% t - vector of magnitudes (independent variable) % t - vector of magnitudes (independent variable)
% y - CDF vector % y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin))); mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian; y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1); idx=find(y>1);
y(idx)=ones(size(idx)); y(idx)=ones(size(idx));
end end

View File

@@ -1,59 +1,59 @@
% [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b) % [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b)
% %
% EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UNLIMITED G-R LED % EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UNLIMITED G-R LED
% MAGNITUDE DISTRIBUTION MODEL. % MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation % DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution % leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of % from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at % this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the % start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode. % unlimited Gutenberg-Richter estimation mode.
% %
% The mean return period of magnitude M is the average elapsed time between % The mean return period of magnitude M is the average elapsed time between
% the consecutive earthquakes of magnitude M. % the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up % The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM. % to Mu with step dM.
% %
%INPUT: %INPUT:
% Md - starting magnitude for return period calculations % Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations % Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations % dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% %
%OUTPUT: %OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu) % m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m % T - vector od mean return periods of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b) function [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
if Md<Mmin; Md=Mmin;end if Md<Mmin; Md=Mmin;end
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
beta=b*log(10); beta=b*log(10);
T=1/lamb./exp(-beta*(m-Mmin+eps/2)); T=1/lamb./exp(-beta*(m-Mmin+eps/2));
end end

View File

@@ -1,94 +1,94 @@
% [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax) % [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax)
% %
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MEAN %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MEAN
% RETURN PERIOD VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC % RETURN PERIOD VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE. % DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand % the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters % side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off % namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the % interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of % scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the % magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with % randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2. % respect to the value Mmin-eps/2.
% %
% The mean return periods are calculated for magnitude starting from Md up % The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM. % to Mu with step dM.
% %
% REFERENCES: % REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, % Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 % Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 % Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% Md - starting magnitude for return period calculations % Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations % Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations % dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu) % m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m % T - vector od mean return periods of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax) function [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
if Md<Mmin; Md=Mmin;end if Md<Mmin; Md=Mmin;end
if Mu>Mmax; Mu=Mmax;end if Mu>Mmax; Mu=Mmax;end
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
n=length(m); n=length(m);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
for i=1:n for i=1:n
CDF_NPT=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian; CDF_NPT=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian;
T(i)=1/lamb./(1-CDF_NPT); T(i)=1/lamb./(1-CDF_NPT);
end end
T=T'; T=T';
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,91 +1,91 @@
% [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd) % [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd)
% %
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES %USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MEAN RETURN PERIOD VALUES FOR THE UNBOUNDED % THE MEAN RETURN PERIOD VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE. % NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side. % the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel % The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the % estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample % scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled % - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2. % symmetrically with respect to the value Mmin-eps/2.
% %
% The mean return period of magnitude M is the average % The mean return period of magnitude M is the average
% elapsed time between the consecutive earthquakes of magnitude M. % elapsed time between the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up % The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM. % to Mu with step dM.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
% INPUT: % INPUT:
% Md - starting magnitude for return period calculations % Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations % Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations % dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin % lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
%OUTPUT: %OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu) % m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m % T - vector od mean return periods of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd) function [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
if Md<Mmin; Md=Mmin;end if Md<Mmin; Md=Mmin;end
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
n=length(m); n=length(m);
for i=1:n for i=1:n
CDF_NPU=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); CDF_NPU=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
T(i)=1/lamb./(1-CDF_NPU); T(i)=1/lamb./(1-CDF_NPU);
end end
T=T'; T=T';
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,250 +1,250 @@
% %
% [lamb_all,lamb,lmab_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin) % [lamb_all,lamb,lmab_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin)
% %
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE % ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE, % COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE,
% THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE % THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE
% DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL % DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !! % GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution and consequently the G-R % Mmin. The shape parameter of this distribution and consequently the G-R
% b-value is estimated by maximum likelihood method (Aki-Utsu procedure). % b-value is estimated by maximum likelihood method (Aki-Utsu procedure).
% The upper limit of the distribution Mmax is evaluated using % The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the % the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used: % Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)). % Mmaxest= 2(max obs M) - (second max obs M)).
% The mean activity rate, lamb, is the number of events >=Mmin into the % The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input % length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year. % parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps is the least non-zero difference % The round-off interval length - eps is the least non-zero difference
% between sample data or 0.1 if the least difference is greater than 0.1. % between sample data or 0.1 if the least difference is greater than 0.1.
% %
% REFERENCES: % REFERENCES:
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654 %Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673, %Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y % doi: 10.2478/s11600-010-0049-y
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog % M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally. % Mmin - catalog completeness level. Must be determined externally.
% Can take any value from [min(M), max(M)]. % Can take any value from [min(M), max(M)].
% %
% OUTPUT: % OUTPUT:
% %
% lamb_all - mean activity rate for all events % lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin % lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 15 or more events >=Mmin and the parameter estimation is % for 15 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except % continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is % lamb_all and lamb are set to zero and the function execution is
% terminated. % terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 - % err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock % no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used. % method used.
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin) function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin)
n=length(M); n=length(M);
lamb_err=0; lamb_err=0;
t1=t(1); t1=t(1);
for i=1:n for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t1=t(i+1); t1=t(i+1);
end end
t2=t(n); t2=t(n);
for i=n:1 for i=n:1
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t2=t(i-1);
end end
nn=0; nn=0;
for i=1:n for i=1:n
if M(i)>=Mmin if M(i)>=Mmin
nn=nn+1; nn=nn+1;
end end
end end
if iop==0 if iop==0
lamb_all=n/round(t(n)-t(1)); lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1); lamb=nn/round(t2-t1);
unit='day'; unit='day';
elseif iop==1 elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014 lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014 lamb=30*nn/(t2-t1); % K20OCT2014
unit='month'; unit='month';
else else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014 lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014 lamb=365*nn/(t2-t1); % K20OCT2014
unit='year'; unit='year';
end end
if nn<15 if nn<15
eps=0;b=0;Mmax=0;err=0; eps=0;b=0;Mmax=0;err=0;
lamb_err=1; lamb_err=1;
return; return;
end end
eps=magn_accur(M); eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014 xx=M(M>=Mmin); %K21OCT2014
% x=sort(M,'descend'); % x=sort(M,'descend');
% for i=1:n % for i=1:n
% if x(i)<Mmin; break; end % if x(i)<Mmin; break; end
% xx(i)=x(i); % % xx(i)=x(i); %
% end % end
clear x; clear x;
nn=length(xx); nn=length(xx);
Max_obs=max(xx); Max_obs=max(xx);
beta0=0; beta0=0;
Mmax1=Max_obs; Mmax1=Max_obs;
for i=1:50, for i=1:50,
beta=fzero(@bet_est,[0.05,4.0],[],mean(xx),Mmin-eps/2,Mmax1); beta=fzero(@bet_est,[0.05,4.0],[],mean(xx),Mmin-eps/2,Mmax1);
Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1); Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1);
if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001)) if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001))
err=0; err=0;
break; break;
end end
Mmax1=Mmax; Mmax1=Mmax;
beta0=beta; beta0=beta;
end end
if i==50; if i==50;
err=1.0; err=1.0;
Mmax=2*xx(1)-xx(2); Mmax=2*xx(1)-xx(2);
beta=fzero(@bet_est,1.0,[],mean(xx),Mmin-eps/2,Mmax); beta=fzero(@bet_est,1.0,[],mean(xx),Mmin-eps/2,Mmax);
end end
b=beta/log(10); b=beta/log(10);
clear xx clear xx
end end
function [zero]=bet_est(b,ms,Mmin,Mmax) function [zero]=bet_est(b,ms,Mmin,Mmax)
%First derivative of the log likelihood function of the upper-bounded %First derivative of the log likelihood function of the upper-bounded
% exponential distribution (truncated GR model) % exponential distribution (truncated GR model)
% b - parameter of the distribution 'beta' % b - parameter of the distribution 'beta'
% ms - mean of the observed magnitudes % ms - mean of the observed magnitudes
% Mmin - catalog completeness level % Mmin - catalog completeness level
% Mmax - upper limit of the distribution % Mmax - upper limit of the distribution
M_max_min=Mmax-Mmin; M_max_min=Mmax-Mmin;
e_m=exp(-b*M_max_min); e_m=exp(-b*M_max_min);
zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m); zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m);
end end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin) function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY % Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated % funfc - string with the name of function to be integrated
% a,b - integration limits % a,b - integration limits
% eps - accurracy % eps - accurracy
% varargin - other parameters of function to be integrated % varargin - other parameters of function to be integrated
% calka - integral % calka - integral
% ier=0 - convergence, ier=1 - no conbergence % ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ... W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ... 0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ... 0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069]; 0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ... X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ... 0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ... 0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637]; 0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12; CONST=1E-12;
delta=CONST*abs(a-b); delta=CONST*abs(a-b);
calka=0.; calka=0.;
aa=a; aa=a;
y=b-aa; y=b-aa;
ier=0; ier=0;
while abs(y)>delta, while abs(y)>delta,
bb=aa+y; bb=aa+y;
c1=0.5*(aa+bb); c1=0.5*(aa+bb);
c2=c1-aa; c2=c1-aa;
s8=0.; s8=0.;
s16=0.; s16=0.;
for i=1:4, for i=1:4,
u=X(i)*c2; u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end end
for i=5:12, for i=5:12,
u=X(i)*c2; u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end end
s8=s8*c2; s8=s8*c2;
s16=s16*c2; s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16)) if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y; y=0.5*y;
calka=0.; calka=0.;
ier=1; ier=1;
else else
calka=calka+s16; calka=calka+s16;
aa=bb; aa=bb;
y=b-aa; y=b-aa;
ier=0; ier=0;
end end
end end
end end
function [y]=f_podc(z,n,beta,Mmin,Mmax) function [y]=f_podc(z,n,beta,Mmin,Mmax)
% Integrated function for Mmax estimation. Truncated GR model % Integrated function for Mmax estimation. Truncated GR model
% z - column vector of independent variable % z - column vector of independent variable
% n - the size of 'z' % n - the size of 'z'
% beta - the distribution parameter % beta - the distribution parameter
% Mmin - the catalog completeness level % Mmin - the catalog completeness level
% Mmax - the upper limit of the distribution % Mmax - the upper limit of the distribution
y=Cdfgr(z,beta,Mmin,Mmax).^n; y=Cdfgr(z,beta,Mmin,Mmax).^n;
end end
function [y]=Cdfgr(t,beta,Mmin,Mmax) function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R %CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model % model
% Mmin - catalog completeness level % Mmin - catalog completeness level
% Mmax - upper limit of the distribution % Mmax - upper limit of the distribution
% beta - the distribution parameter % beta - the distribution parameter
% t - vector of magnitudes (independent variable) % t - vector of magnitudes (independent variable)
% y - CDF vector % y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin))); mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian; y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1); idx=find(y>1);
y(idx)=ones(size(idx)); y(idx)=ones(size(idx));
end end
function [eps]=magn_accur(M) function [eps]=magn_accur(M)
x=sort(M); x=sort(M);
d=x(2:length(x))-x(1:length(x)-1); d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); eps=min(d(d>0));
if eps>0.1; eps=0.1;end if eps>0.1; eps=0.1;end
end end

View File

@@ -1,305 +1,387 @@
% %
% [lamb_all,lamb,lmab_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin) %[lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err,BIAS,SD]=TruncGR_Ob(t,M,iop,Mmin,Mmax,Nsynth)
% %
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE % ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE, % COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE,
% THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE % THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE
% DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL % DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !! % GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project. % AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution and consequently the G-R % Mmin. The shape parameter of this distribution and consequently the G-R
% b-value is estimated by maximum likelihood method (Aki-Utsu procedure). % b-value is estimated by maximum likelihood method (Aki-Utsu procedure).
% The upper limit of the distribution Mmax is evaluated using % The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the % the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used: % Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)). % Mmaxest= 2(max obs M) - (second max obs M)).
% The mean activity rate, lamb, is the number of events >=Mmin into the % The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input % length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year. % parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps is the least non-zero difference % The round-off interval length - eps is the least non-zero difference
% between sample data or 0.1 if the least difference is greater than 0.1. % between sample data or 0.1 if the least difference is greater than 0.1.
% %
% REFERENCES: % REFERENCES:
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654 %Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673, %Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y % doi: 10.2478/s11600-010-0049-y
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog % M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally. % Mmin - catalog completeness level. Must be determined externally.
% Can take any value from [min(M), max(M)]. % Can take any value from [min(M), max(M)].
% % Mmax - upper limit of Magnitude Distribution. Can be set by user, or
% OUTPUT: % estimate within the program - it then should be set as Mmax=[].
% %
% lamb_all - mean activity rate for all events % OUTPUT:
% lamb - mean activity rate for events >= Mmin %
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_all - mean activity rate for all events
% for 15 or more events >=Mmin and the parameter estimation is % lamb - mean activity rate for events >= Mmin
% continued, lamb_err=1 otherwise, all output paramters except % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% lamb_all and lamb are set to zero and the function execution is % for 15 or more events >=Mmin and the parameter estimation is
% terminated. % continued, lamb_err=1 otherwise, all output paramters except
% unit - string with name of time unit used ('year' or 'month' or 'day'). % lamb_all and lamb are set to zero and the function execution is
% eps - length of the round-off interval of magnitudes. % terminated.
% b - Gutenberg-Richter b-value % unit - string with name of time unit used ('year' or 'month' or 'day').
% Mmax - upper limit of magnitude distribution % eps - length of the round-off interval of magnitudes.
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 - % b - Gutenberg-Richter b-value
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock % Mmax - upper limit of magnitude distribution
% method used. % err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% % no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% LICENSE % method used.
% This file is a part of the IS-EPOS e-PLATFORM. % BIAS - Mmax estimation Bias (Lasocki and Urban, 2011)
% % SD - Mmax standard deviation (Lasocki ands Urban, 2011)
% This is free software: you can redistribute it and/or modify it under %
% the terms of the GNU General Public License as published by the Free % LICENSE
% Software Foundation, either version 3 of the License, or % This file is a part of the IS-EPOS e-PLATFORM.
% (at your option) any later version. %
% % This is free software: you can redistribute it and/or modify it under
% This program is distributed in the hope that it will be useful, % the terms of the GNU General Public License as published by the Free
% but WITHOUT ANY WARRANTY; without even the implied warranty of % Software Foundation, either version 3 of the License, or
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % (at your option) any later version.
% GNU General Public License for more details. %
% % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err]=TruncGR_O(t,M,iop,Mmin,Mmax) % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT % GNU General Public License for more details.
t=[1 2];M=[1 2]; end %K30SEP %
n=length(M); function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err,BIAS,SD]=TruncGR_Ob(t,M,iop,Mmin,Mmax,Nsynth)
lamb_err=0; if nargin==5;Nsynth=[];end % K08DEC2019
t1=t(1); if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT
for i=1:n t=[1 2];M=[1 2]; end %K30SEP
if M(i)>=Mmin; break; end
t1=t(i+1); n=length(M);
end lamb_err=0;
t2=t(n); t1=t(1);
for i=n:1 for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t1=t(i+1);
end end
nn=0; t2=t(n);
for i=1:n for i=n:1
if M(i)>=Mmin if M(i)>=Mmin; break; end
nn=nn+1; t2=t(i-1);
end end
end nn=0;
for i=1:n
% SL 03MAR2015 ---------------------------------- if M(i)>=Mmin
[NM,unit]=time_diff(t(1),t(n),iop); nn=nn+1;
lamb_all=n/NM; end
[NM,unit]=time_diff(t1,t2,iop); end
lamb=nn/NM;
% SL 03MAR2015 ---------------------------------- % SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop);
if nn<15 lamb_all=n/NM;
eps=0;b=0;Mmax=0;err=0; [NM,unit]=time_diff(t1,t2,iop);
lamb_err=1; lamb=nn/NM;
return; % SL 03MAR2015 ----------------------------------
end
if nn<15
eps=magn_accur(M); eps=0;b=0;Mmax=0;err=0;
xx=M(M>=Mmin); %K21OCT2014 lamb_err=1;
% x=sort(M,'descend'); BIAS=NaN;SD=NaN; %%% K 08NOV2019
% for i=1:n return;
% if x(i)<Mmin; break; end end
% xx(i)=x(i); %
% end eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014
clear x; % x=sort(M,'descend');
nn=length(xx); % for i=1:n
% if x(i)<Mmin; break; end
Max_obs=max(xx); % xx(i)=x(i); %
beta0=0; % end
Mmax1=Max_obs;
if isempty(Mmax)==0 %%% K 28JUL2015 clear x;
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax); %%% K 28JUL2015 nn=length(xx);
x0 = 1; %[0.05,4.0]; %%% K 28JUL2015 - See exception line 153
beta = fzero(fun,x0); %%% K 28JUL2015 Max_obs=max(xx);
err=0; %%% K 28JUL2015 beta0=0;
else %%% K 28JUL2015 - line 148 Mmax1=Max_obs;
for i=1:50, if isempty(Mmax)==0 %%% K 28JUL2015
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax1); err_Mmax=0; %%% K 04DEC2019
x0 =1; %[0.05,4.0]; %%% K29JUL2015 - See exception line 153 fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax); %%% K 28JUL2015
beta = fzero(fun,x0); x0 = 1; %[0.05,4.0]; %%% K 28JUL2015 - See exception line 155
Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1); beta = fzero(fun,x0); %%% K 28JUL2015
if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001)) err=0; %%% K 28JUL2015
err=0; else %%% K 28JUL2015 - line 150
break; err_Mmax=1; %%% K 04DEC2019
end for i=1:50,
Mmax1=Mmax; fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax1);
beta0=beta; x0 =1; %[0.05,4.0]; %%% K29JUL2015 - See exception line 155
end beta = fzero(fun,x0);
if i==50; Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1);
err=1.0; if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001))
Mmax=2*xx(1)-xx(2); err=0;
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax); break;
x0 =1; end
beta = fzero(fun,x0); Mmax1=Mmax;
end beta0=beta;
end %%% K 28JUL2015 end
b=beta/log(10); if i==50;
clear xx err=1.0;
Mmax=2*xx(1)-xx(2);
% Exception for v-value fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax);
if b<0.05 || b>6.0; error('Unacceptable b-value, abort and select different dataset');end x0 =1;
beta; beta = fzero(fun,x0);
end end
end %%% K 28JUL2015
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 b=beta/log(10);
clear xx
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
% % Exception for v-value
% t1 - start time (in MATLAB numerical format) if b<0.05 || b>6.0; error('Unacceptable b-value, abort and select different dataset');end
% t2 - end time (in MATLAB numerical format) t2>=t1 beta;
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% % Estimation of Mmax Bias %%% K 04DEC2019
% NM - number of time units from t1 to t2 % (Lasocki and Urban, 2011, doi:10.2478/s11600-010-0049-y)
% unit - string with name of time unit used ('year' or 'month' or 'day'). if isempty(Nsynth)==0 && err_Mmax==1 % set number of synthetic datasets, e.g. 10000
[BIAS,SD]=Mmax_Bias_GR(t,M,Mmin,Mmax,b,err,Nsynth);
if iop==0 elseif isempty(Nsynth)==0 && err_Mmax==0;
NM=(t2-t1); warning('Mmax must be empty for BIAS calculation');BIAS=[];SD=[];
unit='day'; else; BIAS=0;SD=0;
elseif iop==1 end
V1=datevec(t1);
V2=datevec(t2); end
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12;
unit='month';
else
V1=datevec(t1); function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
V2=datevec(t2);
NM2=V2(3); % TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
if V2(2)>1 %
for k=1:V2(2)-1 % t1 - start time (in MATLAB numerical format)
NM2=NM2+eomday(V2(1),k); % t2 - end time (in MATLAB numerical format) t2>=t1
end % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
end % iop=2 - 'year'
day2=365; if eomday(V2(1),2)==29; day2=366; end; %
NM2=NM2/day2; % NM - number of time units from t1 to t2
NM1=V1(3); % unit - string with name of time unit used ('year' or 'month' or 'day').
if V1(2)>1
for k=1:V1(2)-1 if iop==0
NM1=NM1+eomday(V1(1),k); NM=(t2-t1);
end unit='day';
end elseif iop==1
day1=365; if eomday(V1(1),2)==29; day1=366; end; V1=datevec(t1);
NM1=(day1-NM1)/day1; V2=datevec(t2);
NM=NM2+NM1+V2(1)-V1(1)-1; NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
unit='year'; +(V2(1)-V1(1)-1)*12;
end unit='month';
end else
V1=datevec(t1);
function [zero]=bet_est(b,ms,Mmin,Mmax) V2=datevec(t2);
NM2=V2(3);
%First derivative of the log likelihood function of the upper-bounded if V2(2)>1
% exponential distribution (truncated GR model) for k=1:V2(2)-1
% b - parameter of the distribution 'beta' NM2=NM2+eomday(V2(1),k);
% ms - mean of the observed magnitudes end
% Mmin - catalog completeness level end
% Mmax - upper limit of the distribution day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2;
M_max_min=Mmax-Mmin; NM1=V1(3);
e_m=exp(-b*M_max_min); if V1(2)>1
zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m); for k=1:V1(2)-1
end NM1=NM1+eomday(V1(1),k);
end
end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin) day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1;
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year';
% funfc - string with the name of function to be integrated end
% a,b - integration limits end
% eps - accurracy
% varargin - other parameters of function to be integrated function [zero]=bet_est(b,ms,Mmin,Mmax)
% calka - integral
% ier=0 - convergence, ier=1 - no conbergence %First derivative of the log likelihood function of the upper-bounded
% exponential distribution (truncated GR model)
persistent W X CONST % b - parameter of the distribution 'beta'
W=[0.101228536290376 0.222381034453374 0.313706645877887 ... % ms - mean of the observed magnitudes
0.362683783378362 0.027152459411754 0.062253523938648 ... % Mmin - catalog completeness level
0.095158511682493 0.124628971255534 0.149595988816577 ... % Mmax - upper limit of the distribution
0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ... M_max_min=Mmax-Mmin;
0.183434642495650 0.989400934991650 0.944575023073233 ... e_m=exp(-b*M_max_min);
0.865631202387832 0.755404408355003 0.617876244402644 ... zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m);
0.458016777657227 0.281603550779259 0.095012509837637]; end
CONST=1E-12;
delta=CONST*abs(a-b);
calka=0.; function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
aa=a;
y=b-aa; % Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
ier=0;
while abs(y)>delta, % funfc - string with the name of function to be integrated
bb=aa+y; % a,b - integration limits
c1=0.5*(aa+bb); % eps - accurracy
c2=c1-aa; % varargin - other parameters of function to be integrated
s8=0.; % calka - integral
s16=0.; % ier=0 - convergence, ier=1 - no conbergence
for i=1:4,
u=X(i)*c2; persistent W X CONST
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
end 0.362683783378362 0.027152459411754 0.062253523938648 ...
for i=5:12, 0.095158511682493 0.124628971255534 0.149595988816577 ...
u=X(i)*c2; 0.169156519395003 0.182603415044924 0.189450610455069];
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:})); X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
end 0.183434642495650 0.989400934991650 0.944575023073233 ...
s8=s8*c2; 0.865631202387832 0.755404408355003 0.617876244402644 ...
s16=s16*c2; 0.458016777657227 0.281603550779259 0.095012509837637];
if abs(s16-s8)>eps*(1+abs(s16)) CONST=1E-12;
y=0.5*y; delta=CONST*abs(a-b);
calka=0.; calka=0.;
ier=1; aa=a;
else y=b-aa;
calka=calka+s16; ier=0;
aa=bb; while abs(y)>delta,
y=b-aa; bb=aa+y;
ier=0; c1=0.5*(aa+bb);
end c2=c1-aa;
end s8=0.;
end s16=0.;
for i=1:4,
function [y]=f_podc(z,n,beta,Mmin,Mmax) u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
% Integrated function for Mmax estimation. Truncated GR model end
% z - column vector of independent variable for i=5:12,
% n - the size of 'z' u=X(i)*c2;
% beta - the distribution parameter s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
% Mmin - the catalog completeness level end
% Mmax - the upper limit of the distribution s8=s8*c2;
s16=s16*c2;
y=Cdfgr(z,beta,Mmin,Mmax).^n; if abs(s16-s8)>eps*(1+abs(s16))
end y=0.5*y;
calka=0.;
function [y]=Cdfgr(t,beta,Mmin,Mmax) ier=1;
else
%CDF of the truncated upper-bounded exponential distribution (truncated G-R calka=calka+s16;
% model aa=bb;
% Mmin - catalog completeness level y=b-aa;
% Mmax - upper limit of the distribution ier=0;
% beta - the distribution parameter end
% t - vector of magnitudes (independent variable) end
% y - CDF vector end
mian=(1-exp(-beta*(Mmax-Mmin))); function [y]=f_podc(z,n,beta,Mmin,Mmax)
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1); % Integrated function for Mmax estimation. Truncated GR model
y(idx)=ones(size(idx)); % z - column vector of independent variable
end % n - the size of 'z'
% beta - the distribution parameter
function [eps]=magn_accur(M) % Mmin - the catalog completeness level
x=sort(M); % Mmax - the upper limit of the distribution
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); y=Cdfgr(z,beta,Mmin,Mmax).^n;
if eps>0.1; eps=0.1;end end
end
function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
% beta - the distribution parameter
% t - vector of magnitudes (independent variable)
% y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1);
y(idx)=ones(size(idx));
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end
% --------------------- Mmax BIAS estimation routine ---------------------- K 08NOV2019
function [BIAS,SD]=Mmax_Bias_GR(t,m,Mc,Mmax1,b,err,synth)
if err~=0
warning('process did not converge!!'),pause
end
MAXm=max(m);beta=b*log(10);N=numel(m(m>=Mc));DeltaM=MAXm-Mc;
for j=1:synth %set number of synthetic datasets, default is 10000
% % CDF:
M=Mc:0.0001:MAXm;upt=1-exp(-beta*(M-Mc));
dwt=1-exp(-beta*(MAXm-Mc));F=upt./dwt; % j
% linear interpolation to assign magnitude values from a uniform distribution sample
iM=rand(1,N);M1=interp1q(F',M',iM');
br(j)=1/(log(10)*(mean(M1)-min(M1)));DM=range(M1);
Mmax=max(M1);
% Iteration Process to estimate b and Mmax
b1=1;best=[1.0 10.0];i=1;
while min(abs(diff(best)))>0.00001
w=exp(b1*(Mmax-Mc));E1=expint(N/(w-1));E2=expint(N*w/(w-1));
%E=expint(w);
Mme=Mmax+(E1-E2)/(b1*exp(-N/(w-1)))+(Mc)*exp(-N); %Mme=round(Mme/EPS)*EPS;
if isnan(Mme)
KM=sort(unique(M1),'descend');
Mme=2*KM(1)-KM(2);
end
fun=@(bb) 1/bb+(Mme-Mc)/(1-exp(bb*(Mme-Mc)))-mean(M1)+Mc; %consider th5 last 0.05 term
b1=fzero(fun,1);best(i)=b1;i=i+1;
if i==50
warning('process did not converge!!');break
end
end
be(j)=b1/log(10);
Me(j)=Mme;dm(j)=DM;Mm(j)=Mmax;
end
BIAS=mean(MAXm-Me)
SD=std(MAXm-Me);
%b-mean(be) %check b-value difference
%histogram(be)
% MAXm: maximum magnitude in the real catalog
% Mmax: maximum magnitudes observed in the synthetic catalogs (rounded)
% Me: maximum magnitude estimates for the synthetic catalogs
% Mmax1: maximum magnitude estimated by GRT
end

View File

@@ -1,162 +1,162 @@
% [lamb_all,lamb,lmab_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin) % [lamb_all,lamb,lmab_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin)
% %
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE % ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE AND THE % COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE AND THE
% GUTENBERG-RICHTER B-VALUE USING THE UNLIMITED G-R LED MAGNITUDE % GUTENBERG-RICHTER B-VALUE USING THE UNLIMITED G-R LED MAGNITUDE
% DISTRIBUTION MODEL % DISTRIBUTION MODEL
% %
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED % !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !! % GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
% %
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project. % AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation % DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution % leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of % from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value is estimated by % this distribution and consequently the G-R b-value is estimated by
% maximum likelihood method (Aki-Utsu procedure). % maximum likelihood method (Aki-Utsu procedure).
% The mean activity rate, lamb, is the number of events >=Mmin into the % The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input % length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year. % parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps if the least non-zero difference % The round-off interval length - eps if the least non-zero difference
% between sample data or 0.1 is the least difference is greater than 0.1. % between sample data or 0.1 is the least difference is greater than 0.1.
% %
% INPUT: % INPUT:
% t - vector of earthquake occurrence times % t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog % M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally. % Mmin - catalog completeness level. Must be determined externally.
% can take any value from [min(M), max(M)]. % can take any value from [min(M), max(M)].
% %
% OUTPUT: % OUTPUT:
% lamb_all - mean activity rate for all events % lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin % lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0 % lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 7 or more events >=Mmin and the parameter estimation is % for 7 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except % continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is % lamb_all and lamb are set to zero and the function execution is
% terminated. % terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>. % along with this program. If not, see <http://www.gnu.org/licenses/>.
% %
function [lamb_all,lamb,lamb_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin) function [lamb_all,lamb,lamb_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin)
if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP t=[1 2];M=[1 2]; end %K30SEP
lamb_err=0; lamb_err=0;
n=length(M); n=length(M);
t1=t(1); t1=t(1);
for i=1:n for i=1:n
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t1=t(i+1); t1=t(i+1);
end end
t2=t(n); t2=t(n);
for i=n:1 for i=n:1
if M(i)>=Mmin; break; end if M(i)>=Mmin; break; end
t2=t(i-1); t2=t(i-1);
end end
nn=0; nn=0;
for i=1:n for i=1:n
if M(i)>=Mmin if M(i)>=Mmin
nn=nn+1; nn=nn+1;
end end
end end
% SL 03MAR2015 ---------------------------------- % SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop); [NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM; lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop); [NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM; lamb=nn/NM;
% SL 03MAR2015 ---------------------------------- % SL 03MAR2015 ----------------------------------
if nn<7 if nn<7
eps=0;b=0; eps=0;b=0;
lamb_err=1; lamb_err=1;
return; return;
end end
eps=magn_accur(M); eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014 xx=M(M>=Mmin); %K21OCT2014
% x=sort(M,'descend'); % x=sort(M,'descend');
% for i=1:n % for i=1:n
% if x(i)<Mmin; break; end % if x(i)<Mmin; break; end
% xx(i)=x(i); % % xx(i)=x(i); %
% end % end
clear x; clear x;
beta=1/(mean(xx)-Mmin+eps/2); beta=1/(mean(xx)-Mmin+eps/2);
b=beta/log(10); b=beta/log(10);
clear xx clear xx
end end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT % TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
% %
% t1 - start time (in MATLAB numerical format) % t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1 % t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month', % iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year' % iop=2 - 'year'
% %
% NM - number of time units from t1 to t2 % NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day'). % unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0 if iop==0
NM=(t2-t1); NM=(t2-t1);
unit='day'; unit='day';
elseif iop==1 elseif iop==1
V1=datevec(t1); V1=datevec(t1);
V2=datevec(t2); V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))... NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12; +(V2(1)-V1(1)-1)*12;
unit='month'; unit='month';
else else
V1=datevec(t1); V1=datevec(t1);
V2=datevec(t2); V2=datevec(t2);
NM2=V2(3); NM2=V2(3);
if V2(2)>1 if V2(2)>1
for k=1:V2(2)-1 for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k); NM2=NM2+eomday(V2(1),k);
end end
end end
day2=365; if eomday(V2(1),2)==29; day2=366; end; day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2; NM2=NM2/day2;
NM1=V1(3); NM1=V1(3);
if V1(2)>1 if V1(2)>1
for k=1:V1(2)-1 for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k); NM1=NM1+eomday(V1(1),k);
end end
end end
day1=365; if eomday(V1(1),2)==29; day1=366; end; day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1; NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1; NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year'; unit='year';
end end
end end
function [eps]=magn_accur(M) function [eps]=magn_accur(M)
x=sort(M); x=sort(M);
d=x(2:length(x))-x(1:length(x)-1); d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0)); eps=min(d(d>0));
if eps>0.1; eps=0.1;end if eps>0.1; eps=0.1;end
end end

View File

@@ -1,64 +1,64 @@
% [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax) % [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax)
% %
% EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE % EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE
% UNDER THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL. % UNDER THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter % DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model % relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level % magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R % Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distribution Mmax are calculated at % b-value and the end-point of the distribution Mmax are calculated at
% start-up of the stationary hazard assessment services in the % start-up of the stationary hazard assessment services in the
% upper-bounded Gutenberg-Richter estimation mode. % upper-bounded Gutenberg-Richter estimation mode.
% %
% The distribution function values are calculated for magnitude starting % The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM. % from Md up to Mu with step dM.
% %
%INPUT: %INPUT:
% Md - starting magnitude for distribution functions calculations % Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations % Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations % dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
%OUTPUT: %OUTPUT:
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu) % m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_GRT - PDF vector of the same length as m % PDF_GRT - PDF vector of the same length as m
% CDF_GRT - CDF vector of the same length as m % CDF_GRT - CDF vector of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax) function [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
beta=b*log(10); beta=b*log(10);
mian=(1-exp(-beta*(Mmax-Mmin+eps/2))); mian=(1-exp(-beta*(Mmax-Mmin+eps/2)));
PDF_GRT=beta*exp(-beta*(m-Mmin+eps/2))/mian; PDF_GRT=beta*exp(-beta*(m-Mmin+eps/2))/mian;
CDF_GRT=(1-exp(-beta*(m-Mmin+eps/2)))/mian; CDF_GRT=(1-exp(-beta*(m-Mmin+eps/2)))/mian;
idx=find(CDF_GRT<0); idx=find(CDF_GRT<0);
PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=zeros(size(idx)); PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=zeros(size(idx));
idx=find(CDF_GRT>1); idx=find(CDF_GRT>1);
PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=ones(size(idx)); PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=ones(size(idx));
end end

View File

@@ -1,61 +1,61 @@
% [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b) % [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b)
% %
% EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE % EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE
% UNDER THE UNLIMITED G-R LED MAGNITUDE DISTRIBUTION MODEL. % UNDER THE UNLIMITED G-R LED MAGNITUDE DISTRIBUTION MODEL.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation % DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution % leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of % from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at % this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the % start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode. % unlimited Gutenberg-Richter estimation mode.
% %
% The distribution function values are calculated for magnitude starting % The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM. % from Md up to Mu with step dM.
% %
%INPUT: %INPUT:
% Md - starting magnitude for distribution functions calculations % Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations % Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations % dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% eps - length of the round-off interval of magnitudes. % eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value % b - Gutenberg-Richter b-value
% %
%OUTPUT: %OUTPUT:
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu) % m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_GRT - PDF vector of the same length as m % PDF_GRT - PDF vector of the same length as m
% CDF_GRT - CDF vector of the same length as m % CDF_GRT - CDF vector of the same length as m
% %
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b) function [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
beta=b*log(10); beta=b*log(10);
PDF_GRU=beta*exp(-beta*(m-Mmin+eps/2)); PDF_GRU=beta*exp(-beta*(m-Mmin+eps/2));
CDF_GRU=1-exp(-beta*(m-Mmin+eps/2)); CDF_GRU=1-exp(-beta*(m-Mmin+eps/2));
idx=find(CDF_GRU<0); idx=find(CDF_GRU<0);
PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=zeros(size(idx)); PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=zeros(size(idx));
idx=find(CDF_GRU>1); idx=find(CDF_GRU>1);
PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=ones(size(idx)); PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=ones(size(idx));
end end

View File

@@ -1,116 +1,116 @@
% [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax) % [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax)
% %
% USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY % USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY
% AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UPPER-BOUNDED MAGNITUDE % AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UPPER-BOUNDED MAGNITUDE
% DISTRIBUTION. % DISTRIBUTION.
% %
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand % the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters % side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off % namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the % interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of % scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the % magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with % randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2. % respect to the value Mmin-eps/2.
% %
% REFERENCES: % REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis, % Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 % Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 % Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
%INPUT: %INPUT:
% Md - starting magnitude for distribution functions calculations % Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations % Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations % dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution % Mmax - upper limit of magnitude distribution
% %
% OUTPUT: % OUTPUT:
% m - vector of the independent variable (magnitude) % m - vector of the independent variable (magnitude)
% PDF_NPT - PDF vector % PDF_NPT - PDF vector
% CDF_NPT - CDF vector % CDF_NPT - CDF vector
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax) function [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
nn=length(m); nn=length(m);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
for i=1:nn for i=1:nn
if m(i)<Mmin-eps/2 if m(i)<Mmin-eps/2
PDF_NPT(i)=0;CDF_NPT(i)=0; PDF_NPT(i)=0;CDF_NPT(i)=0;
elseif m(i)>Mmax elseif m(i)>Mmax
PDF_NPT(i)=0;CDF_NPT(i)=1; PDF_NPT(i)=0;CDF_NPT(i)=1;
else else
PDF_NPT(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2)/mian; PDF_NPT(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2)/mian;
CDF_NPT(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian; CDF_NPT(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian;
end end
end end
PDF_NPT=PDF_NPT';CDF_NPT=CDF_NPT'; PDF_NPT=PDF_NPT';CDF_NPT=CDF_NPT';
end end
function [gau]=dens_npr1(y,x,ambd,h,x1) function [gau]=dens_npr1(y,x,ambd,h,x1)
%Nonparametric adaptive density for a variable from the interval [x1,inf) %Nonparametric adaptive density for a variable from the interval [x1,inf)
% x - the sample data doubled and sorted in the ascending order. Use % x - the sample data doubled and sorted in the ascending order. Use
% "podwajanie.m" first to accmoplish that. % "podwajanie.m" first to accmoplish that.
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
c=sqrt(2*pi); c=sqrt(2*pi);
if y<x1 if y<x1
gau=0; gau=0;
else else
gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h; gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h;
end end
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end

View File

@@ -1,114 +1,114 @@
% [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd) % [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd)
% %
% USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY % USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY
% AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UNLIMITED MAGNITUDE % AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UNLIMITED MAGNITUDE
% DISTRIBUTION. % DISTRIBUTION.
% %
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project. % AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
% %
% DESCRIPTION: The kernel estimator approach is a model-free alternative % DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that % to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side. % the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel % The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the % estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample % scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled % - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2 % symmetrically with respect to the value Mmin-eps/2
% %
% The distribution function values are calculated for magnitude starting % The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM. % from Md up to Mu with step dM.
% %
% REFERENCES: % REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis, %Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London % Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665 %Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37 %Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
% %
%INPUT: %INPUT:
% Md - starting magnitude for distribution functions calculations % Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations % Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations % dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level % Mmin - lower bound of the distribution - catalog completeness level
% eps - length of round-off interval of magnitudes. % eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor. % h - kernel smoothing factor.
% xx - the background sample % xx - the background sample
% ambd - the weigthing factors for the adaptive kernel % ambd - the weigthing factors for the adaptive kernel
% %
% %
%OUTPUT %OUTPUT
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu) % m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_NPU - PDF vector of the same length as m % PDF_NPU - PDF vector of the same length as m
% CDF_NPU - CDF vector of the same length as m % CDF_NPU - CDF vector of the same length as m
% %
% LICENSE % LICENSE
% This file is a part of the IS-EPOS e-PLATFORM. % This file is a part of the IS-EPOS e-PLATFORM.
% %
% This is free software: you can redistribute it and/or modify it under % This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free % the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or % Software Foundation, either version 3 of the License, or
% (at your option) any later version. % (at your option) any later version.
% %
% This program is distributed in the hope that it will be useful, % This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of % but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. % GNU General Public License for more details.
% %
function [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd) function [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016 % -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end if dM<=0;error('Magnitude Step must be greater than 0');end
%---------------------------------------------------------- %----------------------------------------------------------
m=(Md:dM:Mu)'; m=(Md:dM:Mu)';
nn=length(m); nn=length(m);
for i=1:nn for i=1:nn
if m(i)>=Mmin-eps/2 if m(i)>=Mmin-eps/2
PDF_NPU(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2); PDF_NPU(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2);
CDF_NPU(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h)); CDF_NPU(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
else else
PDF_NPU(i)=0; PDF_NPU(i)=0;
CDF_NPU(i)=0; CDF_NPU(i)=0;
end end
end end
PDF_NPU=PDF_NPU';CDF_NPU=CDF_NPU'; PDF_NPU=PDF_NPU';CDF_NPU=CDF_NPU';
end end
function [gau]=dens_npr1(y,x,ambd,h,x1) function [gau]=dens_npr1(y,x,ambd,h,x1)
%Nonparametric adaptive density for a variable from the interval [x1,inf) %Nonparametric adaptive density for a variable from the interval [x1,inf)
% x - the sample data doubled and sorted in the ascending order. Use % x - the sample data doubled and sorted in the ascending order. Use
% "podwajanie.m" first to accmoplish that. % "podwajanie.m" first to accmoplish that.
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
c=sqrt(2*pi); c=sqrt(2*pi);
if y<x1 if y<x1
gau=0; gau=0;
else else
gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h; gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h;
end end
end end
function [Fgau]=Dystr_npr(y,x,ambd,h) function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the %Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf) %interval (-inf,inf)
% x - the sample data % x - the sample data
% ambd - the local scaling factors for the adaptive estimation % ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor % h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated % y - the value of random variable X for which the density is calculated
% gau - the density value f(y) % gau - the density value f(y)
n=length(x); n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n; Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end end