Код: Выделить всё
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import genpareto
import tensorflow_probability as tfp
tfd = tfp.distributions
c = 0.118 # concentration
loc = 17.402
scale = 37.613
gpd_1 = tfd.GeneralizedPareto(loc= loc, scale=scale, concentration=c)
gpd_2 = genpareto(c, loc=loc, scale=scale)
x = np.linspace(0, 100, 200)
# Create first figure with two subplots
fig1, (ax1, ax2) = plt.subplots(1, 2, figsize=(10,5))
ax1.plot(x, gpd_1.prob(x), label="PDF Source Dist.", color='C0', linewidth=5, alpha=0.5)
ax1.set_title('PDF Source Dist. (GenPareto tpd.GeneralizedPareto)')
ax1.legend()
ax2.plot(x, gpd_1.cdf(x), label="CDF Source Dist.", color='C0', linewidth=5, alpha=0.5)
ax2.set_title('CDF Source Dist. (GenPareto tpd.GeneralizedPareto)')
ax2.legend()
fig1.suptitle('GenPareto from tpf.GeneralizedPareto concentration=0.118, loc=17.402, scale=37.613')
fig1.tight_layout(rect=[0, 0, 1, 0.95]) # Avoid title overlap
# Create second figure with two subplots
fig2, (ax1_2, ax2_2) = plt.subplots(1, 2, figsize=(10,5))
ax1_2.plot(x, gpd_2.pdf(x), label="PDF Source Dist.", color='C0', linewidth=5, alpha=0.5)
ax1_2.set_title('PDF Source Dist. (GenPareto Scipy)')
ax1_2.legend()
ax2_2.plot(x, gpd_2.cdf(x), label="CDF Source Dist.", color='C0', linewidth=5, alpha=0.5)
ax2_2.set_title('CDF Source Dist. (GenPareto Scipy)')
ax2_2.legend()
fig2.suptitle('GenPareto from Scipy C=0.118, loc=17.402, scale=37.613')
fig2.tight_layout(rect=[0, 0, 1, 0.95])
plt.show()

Подробнее здесь: https://stackoverflow.com/questions/797 ... difference