Professional Documents
Culture Documents
Engineering Risk Analysis Group, Technische Universität München, 80333 Munich, Germany.
®
want to manipulate and how they relate to each other.
MATLAB
[6]. In general, a MATLAB
®
admits to create programs using objects and ordinary functions together in our codes
class (command classdef), should contain the following main blocks:
properties block: Denes all properties to be associated with a class. Denes attributes of all
properties and default values.
methods block: Denes functions associated with the class and their attributes. The rst method
must have the same name as the class and it is called the constructor.
The specication of probability distributions is paramount in statistical and uncertainty analysis. This
task is not only essential for the denition of probability density functions (PDFs) and cumulative
distribution functions (CDFs), but also for the generation of samples and computation of statistics of
quantities of interest. Therefore, it is desirable to have a software toolbox that allows the use of dierent
types of probabilistic models, in order to combine them with mathematical modeling techniques for
MATLAB
®
some particular applications.
is a well-suited environment for statistical computations. Its statistics and machine
learning toolbox provides functions to describe, analyze, and model data using statistics and machine
learning [5]. However, the information that describes a given distribution not always came in terms
1
of its parameters. In some cases, rst-order moments or point measurements are provided for its
characterization. Consequently, the ERADist class has been designed with the purpose of generating
several types of probability distribution that can be dened either with their parameters, moments or
experimental data.
For several methods in probabilistic assessment and reliability analysis, it is benecial to transform
the basic random variables to an equivalent independent standard normal random variable space. This
allows us to take advantage of the numerous properties of the normal distribution. Depending on the
information available on the distributions of random vectors, there exist several possible transforma-
tions from the space of physical variables to the standardized variable space, e.g. Nataf transformation,
Rosenblatt transformation, Hermite polynomials transformation, among others (see e.g. [3]).
The Nataf transformation ([7]) describes the joint probability density function of random variables
based on their individual marginal distributions and coecients of correlation using a Gaussian copula.
The basic assumption of the underlying distribution model is that the random variables derived from a
marginal transformation to standard normal variables will follow the multivariate normal distribution.
Consider a set of n correlated random variables X = [X1 , ..., Xn ] with known marginal CDFs
FX1 (x1 ), ..., FXn (xn ) and linear correlation matrix R with components,
" !#
Xi − µXi Xj − µXj
ρij = E ,
σ Xi σ Xj
where µ Xi and σXi are the mean and standard deviation of Xi . The Nataf transformation T : X → U
is the composition of two functions T = T2 ◦ T1 ,
First, an associated set of correlated standard normal random variables Û = [Û1 , ..., Ûn ] (with
correlation matrix R0 ) can be obtained by applying:
T2 : Û −→ U = ΓÛ
where, Γ is the square root of the inverse of the correlation matrix R0 , e.g. a Cholesky factor of
R−1
0 . The correlation matrix R0 is called the ctive correlation matrix. In general R0 6= R, but
they are related as:
−1
" ! !#
FX−1
i
(Φ(ûi )) − µ X i
FX j
(Φ(ûj )) − µ Xj
ρij = E
σ Xi σXj
Z Z
1
FX−1 −1
φ2 ûi , ûj ; ρ0ij dûi dûj
= (Φ(û i )) − µ X i
F Xj (Φ(ûj )) − µ X j
σ Xi σ Xj i
where, φ2 is the two-dimensional standard normal PDF with zero means, unit standard deviations
and correlation coecient ρ0ij .
The computation of the coecients ρ0ij may be carried out using iterative procedures. However, it
might be dicult since it involves the resolution of an integral equation (which is not guaranteed
to have a solution, if ρij is too close to 1 or -1), and even if each coecient ρ0ij can be computed,
there is no guarantee that the resulting matrix will be positive denite [2]. When this happens,
a set of semi-empirical formulas relating ρij and ρ0ij based on numerical studies for various types
of random variables can be used [3].
2
After applying the Nataf transformation the joint PDF and CDF of the random vector X can be
computed as [3],
n
fX1 (x1 )fX2 (x2 ) · · · fXn (xn ) Y fX (xi )
i
fX (x) = φn (û; R0 ) = φn (û; R0 )
φ(û1 )φ(û2 ) · · · φ(ûn ) φ(ûi )
i=1
FX (x) = Φ(û; R0 )
The ERANataf class implements not only the Nataf transformation to map a given set of samples
from the physical to the standard space (X2U), but also the inverse Nataf transformation to map the
samples from the standard to the physical space (U2X) and the Jacobians of the two transformations.
Moreover, it computes the joint PDF and CDF of the input correlated random variables, and also it
can generate random samples from the joint PDF.
name Distribution
'binomial' Binomial distribution
'geometric' Geometric distribution
'negativebinomial' Negative binomial distribution
'poisson' Poisson distribution
'uniform' Uniform distribution
'standardnormal' Standard normal distribution
'normal' Normal distribution
'lognormal' Log-Normal distribution
'exponential' Exponential distribution
'gamma' Gamma distribution
'beta' Beta distribution
'gumbelMin' Gumbel distribution (to model minima)
'gumbel' Gumbel distribution (to model maxima)
'frechet' Frechet distribution
'weibull' Weibull distribution
'GEVMin' Generalized extreme value distribution (to model minima)
'GEV' Generalized extreme value distribution (to model maxima)
'pareto' Pareto distribution
'rayleigh' Rayleigh distribution
'chisquare' Chi-Squared distribution
3
It should be noted that MATLAB
® already supports 27 dierent distributions (www.mathworks.
com/help/stats/makedist.html#inputarg_distname).
In our case, the constructor Obj = ERADist(name,opt,val) takes the argument name from our list
of supported probability distributions (20 distributions) given in Table 1.
The argument opt can be chosen as:
PAR: If you want to specify the distribution by its parameters (Table 2).
MOM: If you want to specify the distribution by its rst moments (Table 3).
DATA: If you want to specify the distribution based on some data vector (this option is only
available for some distributions, see Table 4).
4
Table 4: Denition of the distributions by data (DATA).
Finally, the argument val requires the numeric value of the given opt, i.e., the value of the param-
eters if we choose PAR, the value of the moments if we choose MOM, or the data vector (as a column) if
we choose DAT.
Please refer to Section 5 in order to know our supported probability distributions, their
parameters and rst-order moments (mean and standard deviation) denitions.
gumbel is the Gumbel distribution given by denition (see Section 5) and is used to model
the maximum value. gumbelMin is the mirror image of the Gumbel distribution; it is
dened by default in MATLAB
® and is used to model the minimum value.
GEV
dened by default in MATLAB
®
is the generalized extreme value distribution given by denition (see Section 5); it is
and is used to model the maximum value. GEVMin is
the mirror image of the generalized extreme value distribution and is used to model the
minimum.
In order to facilitate the input writing of the ERADist class, the names of
the properties are case insensitive, i.e., it isObj =
the same if you write
ERADist('gumbel','PAR',[a_n,b_n]) or Obj = ERADist('Gumbel','Par',[a_n,b_n])
or Obj = ERADist('GuMbEl','PaR',[a_n,b_n]), etc.
5
A: Lower triangular matrix of the Cholesky decomposition of Rho_Z.
Marginals: Contains all marginal distribution objects.
The constructor Obj = ERANataf(M,Correlation) takes the argument M containing the marginals
of the input correlated random variables expressed as distribution objects (e.g. using the ERADist
class); and the argument Correlation denes the correlation matrix of these random variables.
It is worth mentioning that the calculation of the ctive correlation matrix (i.e. solution of the inte-
4 Application examples
Please also refer to the le input_file.m, which contains some of the examples that will be introduced
in the following.
1. Creating distribution objects: For some distributions the parameters coincide with the rst-order
moments (e.g. Normal distribution).
2. Plotting distributions
6
3. Dierence between gumbelMin and gumbel.
1 % %% fit a Gumbel distribution to minimum values
2 xMinima = min ( randn (1000 ,500) , [] , 2); N1 = length ( xMinima );
3 [ fx1 , nx1 ] = hist ( xMinima , ceil ( sqrt ( N1 )));
4 dist_obj1 = ERADist ( ' gumbelMin ' , ' DATA ' , xMinima );
5
6 %% fit a Gumbel distribution to maximum values
7 xMaxima = max ( randn (1000 ,500) , [] , 2); N2 = length ( xMaxima );
8 [ fx2 , nx2 ] = hist ( xMaxima , ceil ( sqrt ( N2 )));
9 dist_obj2 = ERADist ( ' gumbel ' ,' DATA ' , xMaxima );
10
11 %% plot
12 xx = -5:0.01:5;
13 figure ; hold on ;
14 bar ( nx1 , fx1 /( N1 *( nx1 (2) - nx1 (1))) , ' FaceColor ' ,[0 .7 .7] , ' EdgeColor ' ,[0 1 1]);
15 plot ( xx , dist_obj1 . pdf ( xx ) , 'b ' , ' LineWidth ' ,2);
16 bar ( nx2 , fx2 /( N2 *( nx2 (2) - nx2 (1))) , ' FaceColor ' ,[0 .3 .3] , ' EdgeColor ' ,[0 1 1]);
17 plot ( xx , dist_obj2 . pdf ( xx ) , 'r ' , ' LineWidth ' ,2);
18 legend ( ' hist mindata ' , ' gumbelmin ' , ' hist maxdata ' , ' gumbelmax ');
1 % %% marginal distribution 1
2 alpha = 2; %% shape parameter
3 beta = 1; %% rate parameter
4 M (1) = ERADist ( ' gamma ' , ' PAR ' ,[ alpha , beta ]);
5 %% marginal distribution 2
6 nu = 5; %% degrees of freedom
7 M (2) = ERADist ( ' chisquare ' , ' PAR ' , nu );
8 %% correlation matrix
9 Rho = [ 1.0 0.5;
7
10 0.5 1.0 ];
11
12 %% applying Nataf transformation
13 T_Nataf = ERANataf (M , Rho );
14 %% generation of random samples from the join distribution
15 N = 1 e3 ; %% number of samples
16 X = T_Nataf . random ( N );
17 %% samples in standard space
18 U = T_Nataf . X2U ( X );
19
20 %% plot the samples in physical and standard spaces
21 figure ;
22 subplot (121); plot ( X (1 ,:) , X (2 ,:) , ' bx ' , ' LineWidth ' ,2);
23 title ( ' Physical space ' , ' Interpreter ' , ' Latex ' , ' FontSize ' , 20);
24 xlabel ( ' $X_1$ ' , ' Interpreter ' , ' Latex ' , ' FontSize ' , 20);
25 ylabel ( ' $X_2$ ' , ' Interpreter ' , ' Latex ' , ' FontSize ' , 20);
26 set ( gca , ' FontSize ' ,17);
27 subplot (122); plot ( U (1 ,:) , U (2 ,:) , ' ro ' , ' LineWidth ' ,2); axis equal ;
28 title ( ' Standard space ' , ' Interpreter ' , ' Latex ' , ' FontSize ' , 20);
29 xlabel ( ' $U_1$ ' , ' Interpreter ' , ' Latex ' , ' FontSize ' , 20);
30 ylabel ( ' $U_2$ ' , ' Interpreter ' , ' Latex ' , ' FontSize ' , 20);
31 set ( gca , ' FontSize ' ,17);
1 % %% marginal distribution 1
2 mu = 1;
3 sigma = 0.4;
4 M (1) = ERADist ( ' lognormal ' ,' MOM ' ,[ mu , sigma ]);
5 %% marginal distribution 2
6 M (2) = ERADist ( ' normal ' , ' MOM ' ,[ mu , sigma ]);
7 %% correlation matrix
8 Rho = [ 1.0 0.6
9 0.6 1.0 ];
10 %% applying Nataf transformation
11 T_Nataf = ERANataf (M , Rho );
12
13 %% joint PDF and CDF
14 jointf_X = @( X ) T_Nataf . pdf ( X );
15 jointF_X = @( X ) T_Nataf . cdf ( X );
16
17 %% plot joint PDF
18 n = 50;
19 x1 = linspace (0 ,3 , n );
20 x2 = linspace ( -0.5 ,2.5 , n );
21 [ X1 , X2 ] = meshgrid ( x1 , x2 );
22 ff_x = jointf_X ([ X1 (:) X2 (:)]); ff_x = reshape ( ff_x ,n , n );
23 FF_x = jointF_X ([ X1 (:) X2 (:)]); FF_x = reshape ( FF_x ,n , n );
24 figure ;
25 subplot (121); pcolor ( X1 ,X2 , ff_x ); colorbar ; shading interp ; axis equal tight ;
26 xlabel ( ' $X_1$ ' , ' Interpreter ' , ' Latex ' , ' FontSize ' , 20);
27 ylabel ( ' $X_2$ ' , ' Interpreter ' , ' Latex ' , ' FontSize ' , 20);
28 title ( ' PDF ' ,' Interpreter ' , ' Latex ' ,' FontSize ' , 20);
29 set ( gca , ' FontSize ' ,17);
30 subplot (122); pcolor ( X1 ,X2 , FF_x ); colorbar ; shading interp ; axis equal tight ;
31 xlabel ( ' $X_1$ ' , ' Interpreter ' , ' Latex ' , ' FontSize ' , 20);
32 ylabel ( ' $X_2$ ' , ' Interpreter ' , ' Latex ' , ' FontSize ' , 20);
33 title ( ' CDF ' ,' Interpreter ' , ' Latex ' ,' FontSize ' , 20);
34 set ( gca , ' FontSize ' ,17);
8
Physical space Standard space
25
20 3
15 1
X2
U2
0
10 -1
-2
5 -3
-4
0
0 2 4 6 8 -2 0 2
X1 U1
Figure 1: Samples in physical and standard spaces from the Nataf transformation (Example 6).
PDF CDF
2.5 1.5 2.5
2 2
0.8
1.5 1 1.5
0.6
X2
X2
1 1
0.4
0.5 0.5 0.5
0.2
0 0
-0.5 0 -0.5 0
0 1 2 3 0 1 2 3
X1 X1
Figure 2: Joint PDF and CDF from the Nataf transformation (Example 7).
Binomial
n p
pX (x) = px (1 − p)n−x x ∈ {0, ..., n} n ∈ N0 np np(1 − p)
x
bxc p ∈ [0, 1]
X n i
FX (x) = p (1 − p)n−i
i=0
i
Geometric
1
s
pX (x) = (1 − p)x−1 p x ∈ {1, 2, 3, ...} p ∈ (0, 1] 1−p
p
FX (x) = 1 − (1 − p)x p2
9
Negative
binomial x − 1 r s
pX (x) = (1 − p)x−r pr x ∈ {r, r + 1, ...} r∈N r(1 − p)
r−1 p
x
p ∈ (0, 1) p2
X i − 1
FX (x) = (1 − p)i−r pr
i=r
r − 1
Poisson
√ √
λx exp (−λ) (vt)x exp (−vt) x ∈ {0, 1, 2, ...} λ>0 λ = vt λ= vt
pX (x) = =
x! x! or
bxc i
X λ v >0, t > 0
FX (x) = exp (−λ)
i=0
i!
Exponential
Gamma
λk xk−1 exp(−λx) k
r
x ∈ [0, ∞) k>0 k
fX (x) =
Γ(k) λ>0 λ λ2
γ(k, λx)
FX (x) =
Γ(k)
Beta
(x − a)α−1 (b − x)β−1 aβ + bα
s
x ∈ (a, b) α>0 αβ(b − a)
fX (x) =
B(α, β)(b − a)α+β−1 β>0 α+β (α + β)2 (α + β + 1)
FX (x) = Ix (α, β) (a < b) ∈ R
Gumbel
Min
1
s
fX (x) = exp(z − exp(z)) x ∈ (−∞, ∞) bn ∈ R − bn + an γ π 2 a2n
an
an > 0 γ ≈ 0.577216 6
FX (x) = exp(− exp(z))
x − bn
with z =
an
Gumbel
(Max)
1
s
fX (x) = exp(−z − exp(−z)) x ∈ (−∞, ∞) bn ∈ R bn + an γ π 2 a2n
an
an > 0 γ ≈ 0.577216 6
FX (x) = exp(− exp(−z))
x − bn
with z =
an
Fréchet
k an k+1 an k x ∈ [0, ∞) an ∈ (0, ∞) 1 2
fX (x) = exp − an Γ 1 − an Γ 1 − −
an x x k ∈ (0, ∞) k k
1/2
an k for k > 1
1
FX (x) = exp − Γ2 1 −
x k
for k > 2
10
Weibull
k−1 k !
2
k x x x ∈ [0, ∞) an ∈ (0, ∞) an Γ(1 + 1/k) an Γ 1 + −
fX (x) = exp − k
an an an k ∈ (0, ∞)
1/2
k ! 1
Γ2 1 +
x
FX (x) = 1 − exp − k
an
GEV
1 Γ(1 − ξ) − 1
q
fX (x) = (t(x))ξ+1 exp(−t(x)) x ∈ [µ − σ/ξ, ∞) µ∈R µ+σ σ 2 (g2 − g12 )/ξ 2
σ ξ
x ∈ (−∞, µ − σ/ξ] σ>0
FX (x) = exp(−t(x)) for ξ 6= 0, ξ < 1/2
ξ∈R
−1/ξ for ξ 6= 0, ξ < 1 where gk = Γ(1 − kξ)
with t(x) = 1 + ( x−µ
σ
)ξ
Pareto
α xα α xm s
fX (x) = m x ∈ [xm , ∞) xm > 0 x2m α
xα+1 α−1
x α α>0 (α − 1)2 (α − 2)
m for α > 1
FX (x) = 1 −
x for α > 2
Rayleigh
x r r
fX (x) = exp(−x2 /2σ 2 ) x ∈ [0, ∞) σ>0 σ
π 4−π 2
σ2 σ
2 2
FX (x) = 1 − exp(−x2 /2σ 2 )
Chi-
squared √
1 k
x
fX (x) = x( 2 −1) exp −
k
x ∈ [0, ∞) k ∈ N>0 k 2k
2 Γ k2 2 2
1 k x
FX (x) = γ ,
Γ k 2 2
2
Uniform
( q
1 1
b−a
x ∈ [a, b] x ∈ [a, b] −∞ < a < ∞ 2
(a + b) 1
(b − a)2
fX (x) = 12
0 otherwise −∞ < b < ∞
0
x<a
x−a
FX (x) = x ∈ [a, b)
b−a
1 x≥b
Standard
normal
1 1 u∈R − 0 1
φ(u) = √ exp − u2
2π 2
Z u
1
exp −t2 /2 dt
Φ(x) = √
2π −∞
Normal
(x − µ)2
1 x∈R µ∈R µ σ
fX (x) = √ exp −
2σ 2 π 2σ 2 σ>0
1 x−µ
FX (x) = 1 + erf √
2 σ 2
11
Log-
normal 2
(ln(x) − µ)2
q
fX (x) =
1
√exp − x ∈ (0, ∞) µ∈R eµ+(σ /2)
(eσ2− 1)e2µ+σ2
xσ 2π 2σ 2
σ>0
1 1 ln x − µ
FX (x) = + erf √
2 2 2σ
In order to compute some of the previous expressions the following special functions are required:
Rx
B(x; a, b) 0 ta−1 (1 − t)b−1 dt
Ix (a, b) = =
B(a, b) B(a, b)
References
[1] Govindjee, S. (2013) - Object Oriented Programming and Classes in MATLAB. Lecture notes. http:
//www.ce.berkeley.edu/~sanjay/e7/oop.pdf.
[2] Lebrun, Régis and Anne Dutfoy (2009) - An innovating analysis of the Nataf transformation from the
copula viewpoint. Probabilistic Engineering Mechanics 24(3), 312-320.
[4] Liu, Pei-Ling and Armen Der Kiureghian (1986) - Multivariate distribution models with prescribed
marginals and covariances. Probabilistic Engineering Mechanics 1(2), 105-112.
[8] Straub, Daniel (2015) - Lecture notes in Engineering Risk Analysis. Engineering Risk Analysis Group,
Technische Universität München.
12