def monte_carlo_sens_nonlin(Ns, jpdf, sample_method='R'): N_prms = len(jpdf) # 1. Generate sample matrices XA, XB, XC = generate_sample_matrices_mc(Ns, N_prms, jpdf, sample_method) # 2. Evaluate the model Y_A, Y_B, Y_C = evaluate_non_additive_linear_model(XA, XB, XC) # 3. Approximate the sensitivity indices S, ST = calculate_sensitivity_indices_mc(Y_A, Y_B, Y_C) return XA, XB, XC, Y_A, Y_B, Y_C, S, ST
def mc_sensitivity_linear(Ns, jpdf, w, sample_method='R'): Nrv = len(jpdf) # 1. Generate sample matrices A, B, C = generate_sample_matrices_mc(Ns, Nrv, jpdf, sample_method) # 2. Evaluate the model Y_A, Y_B, Y_C = evaluate_linear_model(A, B, C, w) # 3. Approximate the sensitivity indices S, ST = calculate_sensitivity_indices_mc(Y_A, Y_B, Y_C) return A, B, C, Y_A, Y_B, Y_C, S, ST
plt.plot(samples[k], Y_area[0] * unit_m2_cm2, '.', color=color) plt.ylabel('Area [cm2]') plt.ylim([3.45, 4.58]) xlbl = 'Z' + str(k) plt.xlabel(xlbl) plt.tight_layout() # end scatter plots # start Monte Carlo pressure_range = np.linspace(45, 180, 100) * unit_mmhg_pa Ns = 50000 sample_method = 'R' number_of_parameters = len(jpdf) # 1. Generate sample matrices A, B, C = generate_sample_matrices_mc(Ns, number_of_parameters, jpdf, sample_method) plt.figure('mean') print("\n Uncertainty measures (averaged)\n") print('\n E(Y) | Std(Y) \n') for model, name, color in [ (quadratic_area_model, 'Quadratic model', '#dd3c30'), (logarithmic_area_model, 'Logarithmic model', '#2775b5') ]: # evaluate the model for all samples Y_A = model(pressure_range, A.T) Y_B = model(pressure_range, B.T) Y_C = np.empty((len(pressure_range), Ns, number_of_parameters)) for i in range(number_of_parameters): Y_C[:, :, i] = model(pressure_range, C[i, :, :].T)