Esempio n. 1
0
import matplotlib.pyplot as plt
from ERANataf import ERANataf
from ERADist import ERADist
from iTMCMC import iTMCMC
matplotlib.rcParams.update({'font.size': 22})
matplotlib.rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})
matplotlib.rcParams['text.usetex'] = True
plt.close('all')

# %% prior
n = 1  # number of random variables (dimensions)

# assign data: 1st variable is normal
mu_x = 0
sigma_x = 1
dist_x1 = ERADist('normal', 'PAR', [mu_x, sigma_x])

# distributions
dist_X = [dist_x1]

# correlation matrix
R = np.eye(n)  # independent case

# object with distribution information
T_nataf = ERANataf(dist_X, R)

# %% likelihood
y_tilde = 2
mu_nu = 0
sigma_nu = 0.5
likelihood = lambda x: sp.stats.norm.pdf(
Esempio n. 2
0
Based on:
1."Cross entropy-based importance sampling 
   using Gaussian densities revisited"
   Geyer et al.
   Engineering Risk Analysis Group, TUM (Sep 2017)
2. "Sequential importance sampling for structural reliability analysis"
   Papaioannou et al.
   Structural Safety 62 (2016) 66-75   
---------------------------------------------------------------------------
"""

# %% definition of the random variables
d = 2  # number of dimensions
pi_pdf = list()
for i in range(d):
    pi_pdf.append(ERADist('standardnormal', 'PAR', np.nan))  # n independent rv

# correlation matrix
R = np.eye(d)  # independent case

# object with distribution information
pi_pdf = ERANataf(pi_pdf, R)  # if you want to include dependence

# %% limit-state function
g = lambda x: 0.1 * (x[0, :] - x[1, :])**2 - (x[0, :] + x[1, :]) / np.sqrt(
    2) + 2.5

# %% CE-method
N = 1000  # Total number of samples for each level
rho = 0.1  # Cross-correlation coefficient for conditional sampling
k_init = 3  # Initial number of distributions in the Mixture Model (GM/vMFNM)
Esempio n. 3
0
---------------------------------------------------------------------------
Based on:
1."Estimation of small failure probabilities in high dimentions by SuS"
   Siu-Kui Au & James L. Beck.
   Probabilistic Engineering Mechanics 16 (2001) 263-277.
2."MCMC algorithms for subset simulation"
   Papaioannou et al.
   Probabilistic Engineering Mechanics 41 (2015) 83-103.
---------------------------------------------------------------------------
"""

# %% definition of the random variables
d = 100  # number of dimensions
pi_pdf = list()
for i in range(d):
    pi_pdf.append(ERADist('exponential', 'PAR', 1))  # n independent rv

# correlation matrix
# R = eye(d)   # independent case

# object with distribution information
# pi_pdf = ERANataf(pi_pdf,R)    # if you want to include dependence

# %% limit-state function
Ca = 140
g = lambda x: Ca - np.sum(x)

# %% Subset simulation
N = 1000  # Total number of samples for each level
p0 = 0.1  # Probability of each subset, chosen adaptively
alg = 'acs'  # Sampling Algorithm (either 'acs' or 'mma')
Esempio n. 4
0
---------------------------------------------------------------------------
Version 2018-03
---------------------------------------------------------------------------
References:
1."Structural reliability"
   Lemaire et al. (2009)
   Wiley-ISTE.
2."Lecture Notes in Structural Reliability"
   Straub (2016)
---------------------------------------------------------------------------
"""

# %% definition of the random variables
d = 2  # number of dimensions/random variables
pi_pdf = list()
pi_pdf.append(ERADist('normal', 'PAR', [1, 0.4]))  # x1 ~ normpdf(1,0.4)
pi_pdf.append(
    ERADist('exponential', 'PAR',
            [5]))  # x2 ~ exppdf(5) --mu = 1/L = 0.2 --std = 1/L = 0.2

# correlation matrix
R = np.eye(d)  # independent case

# object with distribution information
pi_pdf = ERANataf(pi_pdf, R)  # if you want to include dependence

# %% limit state function and its gradient in the original space
G = lambda x: x[0, :] - x[1, :]  # limit state function in original space
DG = lambda x: np.array([1, -1]
                        )  # gradient of limit state function in original space
Esempio n. 5
0
# find lognormal X1 parameters
var_fun = lambda mu: std_log_X1**2 - (np.exp(mu-np.log(mod_log_X1))-1) \
                                     *np.exp(2*mu+(mu-np.log(mod_log_X1)))
mu_X1 = sp.optimize.fsolve(var_fun, 1)  # mean of the associated Gaussian
std_X1 = np.sqrt(mu_X1 - np.log(mod_log_X1))  # std of the associated Gaussian

# find lognormal X2 parameters
var_X2 = lambda mu: std_log_X2**2 - (np.exp(mu-np.log(mod_log_X2))-1) \
                                    *np.exp(2*mu+(mu-np.log(mod_log_X2)))
mu_X2 = sp.optimize.fsolve(var_X2, 0)  # mean of the associated Gaussian
std_X2 = np.sqrt(mu_X2 - np.log(mod_log_X2))  # std of the associated Gaussian

# %% definition of the random variables
n = 2  # number of random variables (dimensions)
# assign data: 1st variable is Lognormal
dist_x1 = ERADist('lognormal', 'PAR', [mu_X1, std_X1])
# assign data: 2nd variable is Lognormal
dist_x2 = ERADist('lognormal', 'PAR', [mu_X2, std_X2])

# distributions
dist_X = [dist_x1, dist_x2]
# correlation matrix
R = np.eye(n)  # independent case

# object with distribution information
T_nataf = ERANataf(dist_X, R)

# %% likelihood function
lam = np.array([1, 1])  # means of the prediction error
i = 9  # simulation level
var_eps = 0.5**(i - 1)  # variance of the prediction error
Esempio n. 6
0
Technische Universitat Munchen
www.era.bgu.tum.de
---------------------------------------------------------------------------
Version 2018-03
---------------------------------------------------------------------------
References:
1."Bayesian updating with structural reliability methods"
   Daniel Straub & Iason Papaioannou.
   Journal of Engineering Mechanics 141.3 (2015) 1-13.
---------------------------------------------------------------------------
"""

# %% definition of the random variables
n = 12  # number of random variables (dimensions)
# assign data: 1st variable is Lognormal
dist_x = ERADist('standardnormal', 'PAR', [0, 1])

# distributions
dist_X = list()
for i in range(n):
    dist_X.append(dist_x)
# correlation matrix
R = np.eye(n)  # independent case

# object with distribution information
T_nataf = ERANataf(dist_X, R)

# %% likelihood function
mu_l = 0.462
sigma_l = 0.6
likelihood = lambda u: np.prod(sp.stats.norm.pdf(
Esempio n. 7
0
Technische Universitat Munchen
www.era.bgu.tum.de
---------------------------------------------------------------------------
Version 2017-10
---------------------------------------------------------------------------
References:
1. ERADist-ERANataf documentation
---------------------------------------------------------------------------
'''
plt.close('all')
np.random.seed(2017)
example = 2

M = list()
if (example == 1):
    M.append(ERADist('normal', 'PAR', [4, 2]))
    M.append(ERADist('gumbel', 'MOM', [1, 2]))
    M.append(ERADist('exponential', 'PAR', [4]))
    Rho = np.array([[1.0, 0.5, 0.5], [0.5, 1.0, 0.5], [0.5, 0.5, 1.0]])
elif (example == 2):
    M.append(ERADist('rayleigh', 'PAR', 1))
    M.append(ERADist('gumbel', 'MOM', [0, 1]))
    Rho = np.array([[1.0, 0.6], [0.6, 1.0]])
elif (example == 3):
    M.append(ERADist('gamma', 'PAR', [2, 1]))
    M.append(ERADist('chisquare', 'PAR', 5))
    Rho = np.array([[1.0, 0.5], [0.5, 1.0]])
elif (example == 4):
    M.append(ERADist('gamma', 'PAR', [1, 2]))
    M.append(ERADist('weibull', 'PAR', [4, 5]))
    Rho = np.array([[1.0, 0.1], [0.1, 1.0]])