You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current PDF plots require on a histogram and frequently we don't have enough data to have 100 bins and the plots can look distorted
it is suggested to add an option to have powerlaw PDF and CCDF plots directly
Here's an example of a CCDF
import numpy as np
import matplotlib.pyplot as plt
import powerlaw
# Generate some heavy-tailed data, e.g., from a Pareto distribution
data = esd1#np.random.pareto(a=2, size=1000) + 1
# Fit the data to a power-law
fit = powerlaw.Fit(data, discrete=False)
# Plot
plt.figure(figsize=(10, 7))
# Empirical Data CCDF
powerlaw.plot_ccdf(data, color='b', linestyle='-', label="Empirical Data")
# Power-law Fit CCDF
fit.power_law.plot_ccdf(ax=plt.gca(), color='r', linestyle='--', label=f"Powerlaw Fit (alpha={fit.alpha:.2f})")
plt.xlabel('Value')
plt.ylabel('CCDF')
plt.title('CCDF of Empirical Data and Powerlaw Fit')
plt.legend()
plt.grid(True, which="both", ls="--", c='0.7')
plt.show()
The text was updated successfully, but these errors were encountered:
We could also add back the PDF from powerlaw
BUT we need to run Powerlaw to do these--
import numpy as np
import matplotlib.pyplot as plt
import powerlaw
# Generate some heavy-tailed data, e.g., from a Pareto distribution
data = esd1#np.random.pareto(a=2, size=1000) + 1
# Fit the data to a power-law
fit = powerlaw.Fit(data, discrete=False)
# Plot
fig, ax1 = plt.subplots(figsize=(10, 7))
# PDF (on primary y-axis)
powerlaw.plot_pdf(data, ax=ax1, color='b', linestyle='-', label="Empirical Data PDF")
fit.power_law.plot_pdf(ax=ax1, color='r', linestyle='--', label=f"Powerlaw Fit PDF (alpha={fit.alpha:.2f})")
ax1.set_xlabel('Value')
ax1.set_ylabel('PDF')
ax1.tick_params('y', colors='b')
ax1.legend(loc='upper left')
ax1.grid(True, which="both", ls="--", c='0.7')
# CCDF (on secondary y-axis)
ax2 = ax1.twinx()
powerlaw.plot_ccdf(data, ax=ax2, color='green', linestyle=':', label="Empirical Data CCDF", marker='o', markersize=3)
fit.power_law.plot_ccdf(ax=ax2, color='orange', linestyle='-.', label=f"Powerlaw Fit CCDF (alpha={fit.alpha:.2f})")
ax2.set_ylabel('CCDF')
ax2.tick_params('y', colors='r')
ax2.legend(loc='upper right')
plt.title('PDF and CCDF of Empirical Data and Powerlaw Fit')
plt.show()
The current PDF plots require on a histogram and frequently we don't have enough data to have 100 bins and the plots can look distorted
it is suggested to add an option to have powerlaw PDF and CCDF plots directly
Here's an example of a CCDF
The text was updated successfully, but these errors were encountered: