stationary seismic hazard analysis scripts added
This commit is contained in:
110
src/StationarySeismicHazardAnalysis/dist_NPT.m
Normal file
110
src/StationarySeismicHazardAnalysis/dist_NPT.m
Normal file
@@ -0,0 +1,110 @@
|
||||
% [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
|
||||
% AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UPPER-BOUNDED MAGNITUDE
|
||||
% DISTRIBUTION.
|
||||
%
|
||||
% AUTHOR: Stanislaw. Lasocki, Institute of Geophysics Polish Academy of
|
||||
% Sciences, Warsaw, Poland
|
||||
%
|
||||
% DESCRIPTION: The kernel estimator approach is a model-free alternative
|
||||
% to estimating the magnitude distribution functions. It is assumed that
|
||||
% the magnitude distribution has a hard end point Mmax from the right hand
|
||||
% side.The estimation makes use of the previously estimated parameters
|
||||
% namely the mean activity rate lamb, the length of magnitude round-off
|
||||
% interval, eps, the smoothing factor, h, the background sample, xx, the
|
||||
% scaling factors for the background sample, ambd, and the end-point of
|
||||
% magnitude distribution Mmax. The background sample,xx, comprises the
|
||||
% randomized values of observed magnitude doubled symmetrically with
|
||||
% respect to the value Mmin-eps/2.
|
||||
%
|
||||
% REFERENCES:
|
||||
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
|
||||
% Chapman and Hall, London
|
||||
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
|
||||
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
|
||||
%
|
||||
%INPUT:
|
||||
% Md - starting magnitude for distribution functions calculations
|
||||
% Mu - ending magnitude for distribution functions calculations
|
||||
% dM - magnitude step for distribution functions calculations
|
||||
% Mmin - lower bound of the distribution - catalog completeness level
|
||||
% eps - length of round-off interval of magnitudes.
|
||||
% h - kernel smoothing factor.
|
||||
% xx - the background sample
|
||||
% ambd - the weigthing factors for the adaptive kernel
|
||||
% Mmax - upper limit of magnitude distribution
|
||||
%
|
||||
% OUTPUT:
|
||||
% m - vector of the independent variable (magnitude)
|
||||
% PDF_NPT - PDF vector
|
||||
% CDF_NPT - CDF vector
|
||||
%
|
||||
% LICENSE
|
||||
% This file is a part of the IS-EPOS e-PLATFORM.
|
||||
%
|
||||
% 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
|
||||
% Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% This program is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details , <http://www.gnu.org/licenses/>.
|
||||
%
|
||||
|
||||
function [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax)
|
||||
|
||||
m=(Md:dM:Mu)';
|
||||
nn=length(m);
|
||||
|
||||
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
|
||||
for i=1:nn
|
||||
if m(i)<Mmin-eps/2
|
||||
PDF_NPT(i)=0;CDF_NPT(i)=0;
|
||||
elseif m(i)>Mmax
|
||||
PDF_NPT(i)=0;CDF_NPT(i)=1;
|
||||
else
|
||||
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;
|
||||
end
|
||||
end
|
||||
PDF_NPT=PDF_NPT';CDF_NPT=CDF_NPT';
|
||||
end
|
||||
|
||||
function [gau]=dens_npr1(y,x,ambd,h,x1)
|
||||
|
||||
%Nonparametric adaptive density for a variable from the interval [x1,inf)
|
||||
|
||||
% x - the sample data doubled and sorted in the ascending order.
|
||||
% ambd - the local scaling factors for the adaptive estimation
|
||||
% h - the optimal smoothing factor
|
||||
% y - the value of random variable X for which the density is calculated
|
||||
% gau - the density value f(y)
|
||||
|
||||
n=length(x);
|
||||
c=sqrt(2*pi);
|
||||
if y<x1
|
||||
gau=0;
|
||||
else
|
||||
gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function [Fgau]=Dystr_npr(y,x,ambd,h)
|
||||
|
||||
%Nonparametric adaptive cumulative distribution for a variable from the
|
||||
%interval (-inf,inf)
|
||||
|
||||
% x - the sample data
|
||||
% ambd - the local scaling factors for the adaptive estimation
|
||||
% h - the optimal smoothing factor
|
||||
% y - the value of random variable X for which the density is calculated
|
||||
% gau - the density value f(y)
|
||||
|
||||
n=length(x);
|
||||
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user