Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
fit depth as well
Browse files Browse the repository at this point in the history
  • Loading branch information
SichangHe committed Jan 10, 2024
1 parent cf00b74 commit f3a25d0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions scripts/scripts/stats/as_set_size_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,35 @@ def main():
plt.title("Fitted Zipf Distribution vs Empirical Data")
plt.show()

# Fitting depths.
df = df_wo_hash[df_wo_hash["depth"] > 0]
res = fit(zipf, df["depth"], [(1.0, 10.0)])
print(res)
(alpha, loc) = res.params

n_bin = 1000
max_size = max(df["depth"])

x = range(1, max_size + 1)
fitted_data = zipf.pmf(x, alpha, loc=loc)

# Plotting the fitted distribution against the empirical data
plt.bar(x, fitted_data, alpha=0.5, color="yellow", label="Fitted Zipf Distribution")
plt.hist(
df["depth"],
bins=n_bin,
density=True,
alpha=0.5,
color="blue",
label="Empirical Data",
)
plt.legend()
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.xscale("log")
plt.yscale("log")
plt.title("Fitted Zipf Distribution vs Empirical Data")
plt.show()


main() if __name__ == "__main__" else None

0 comments on commit f3a25d0

Please sign in to comment.