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 f_tilde = np.array([3.13, 9.83]) # measured eigenfrequencies [Hz] # shear building model f = lambda x: shear_building_2DOF(m1, m2, kn * x[0], kn * x[1]) # modal measure-of-fit function J = lambda x: np.sum((lam**2) * (((f(x)**2) / f_tilde**2) - 1)**2) # likelihood function likelihood = lambda x: np.exp(-J(x) / (2 * var_eps))
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 = 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 Ca = 140 g = lambda x: Ca - np.sum(x) dg = lambda x: np.tile([-1], [d, 1]) # %% Solve the optimization problem of the First Order Reliability Method # OPC 1. FORM using Hasofer-Lind-Rackwitz-Fiessler algorithm HLRF (Ref.1 Pag.128) [u_star_hlrf, x_star_hlrf, beta_hlrf, Pf_hlrf] = FORM_HLRF(g, dg, pi_pdf) # OPC 2. FORM using Python scipy.optimize.minimize() [u_star_fmc, x_star_fmc, beta_fmc, Pf_fmc] = FORM_fmincon(g, pi_pdf) # exact solution
""" # %% 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( (u - mu_l) / sigma_l), axis=0) / sigma_l realmin = np.finfo(np.double).tiny # realmin to avoid Inf values in log(0) log_likelihood = lambda u: np.log(likelihood(u) + realmin) # %% aBUS-SuS N = 2000 # number of samples per level p0 = 0.1 # probability of each subset # run the BUS_SuS.m function [h, samplesU, samplesX, cE, c, lam_new] = aBUS_SuS(N, p0, log_likelihood,
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]]) # applying Nataf transformation T_Nataf = ERANataf(M, Rho) # generation of of random samples from the joint distribution N = 1000 X = T_Nataf.random(N) # samples in standard space U = T_Nataf.X2U(X) # samples in physical space X = T_Nataf.U2X(U) n = len(M) xx = np.zeros(shape=[n, N]) f_X = np.zeros(shape=[n, N]) F_X = np.zeros(shape=[n, N])