dist1 = LognormalDistribution(sigma=ref_sigma, mu=ref_mu) dep1 = (0, None, 0) distributions = [dist0, dist1] dependencies = [dep0, dep1] mul_dist = MultivariateDistribution(distributions, dependencies) ref_marg_f0 = mul_dist.marginal_pdf(np.squeeze(x), dim=0) ref_marg_f1 = mul_dist.marginal_pdf(np.squeeze(x), dim=1) ref_marg_F0 = mul_dist.marginal_cdf(np.squeeze(x), dim=0) ref_marg_F1 = mul_dist.marginal_cdf(np.squeeze(x), dim=1) ref_marg_x0 = mul_dist.marginal_icdf(p, dim=0) ref_marg_x1 = mul_dist.marginal_icdf(p, dim=1) # %% plt.close("all") plt.figure() plt.plot(x, my_marg_f0, label="my marginal pdf dim=0") plt.plot(x, ref_marg_f0, label="ref marginal pdf dim=0") plt.legend() plt.figure() plt.plot(x, my_marg_f1, label="my marginal pdf dim=1") plt.plot(x, ref_marg_f1, label="ref marginal pdf dim=1") plt.legend() plt.figure() plt.plot(x, my_marg_F0, label="my marginal cdf dim=0")
CS = axs[0].contour(h_grid, s_grid, f, [fm], colors=c, label=[l]) # Now transform the contour to tp hs_s_contour = CS.allsegs[0][0] hs_contour = hs_s_contour[:, 0] s_contour = hs_s_contour[:, 1] tp_contour = np.sqrt((2 * math.pi * hs_contour) / (g * s_contour)) axs[2].plot(tp_contour, hs_contour, c=c) sorted_s = np.sort(steepness) sorted_s = sorted_s[0::100] n = sorted_s.size i = np.array(range(n)) + 1 pi = np.divide((i - 0.5), n) steepness_dist = joint_dist.distributions[1] #theoretical_quantiles = steepness_dist.i_cdf(pi) theoretical_quantiles = joint_dist.marginal_icdf(pi, dim=1) color_sample = 'k' marker_sample = 'x' marker_size = 10 color_fit = 'b' axs[1].scatter(theoretical_quantiles, sorted_s, c=color_sample, s=marker_size, marker=marker_sample, linewidths=1, alpha=0.5, rasterized=True) axs[1].plot([0, max(theoretical_quantiles)], [0, max(theoretical_quantiles)], c=color_fit)
mc_hs = mc_sample[1] # Probability - Quantile plot for i, x in enumerate(variable_list): x_ordered, F = ecdf(x) alpha = 1 - F tr = 1 / (alpha * 365.25 * 24) tr_threshold = 0.0001 axs1[i].plot(tr[tr >= tr_threshold], x_ordered[tr >= tr_threshold], 'ok', markerfacecolor='none', ms=3, rasterized=True) if i == 0: model_ordered = joint_model_4.marginal_icdf(F, i) else: model_ordered, F = ecdf(mc_hs) alpha = 1 - F tr = 1 / (alpha * 365.25 * 24) # Highest F would be 1, which would lead to x_model = inf for unbounded models --> exclude highest value mask = (tr >= tr_threshold) & (tr < 50) axs1[i].plot(tr[mask], model_ordered[mask], rasterized=True) axs1[i].set_xscale('log') axs1[i].set_ylabel(var_labels[i].capitalize()) axs1[i].set_xlabel('Return period (years)') axs1[0].legend(['Empirical', 'Model'], loc='upper left', ncol=1,