Created
October 21, 2023 18:35
-
-
Save cavedave/1f071567382ff40a4d9f3b9dec6ef97a to your computer and use it in GitHub Desktop.
heaps law graph to draw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
unique = [] | |
check = [] | |
k = 50 #These need to be estimated for particular languages but this is a base estimate | |
b=0.4 # | |
for x in range(1, 100000, 100): | |
unique.append(k*(x**b)) | |
check.append(x) | |
# Create a line plot | |
plt.plot(check, unique, color='blue') | |
plt.xlabel('Words read') | |
plt.ylabel('Individual Words seen') | |
plt.title('Heap\'s Law of unique words') | |
# Show the plot | |
plt.show() | |
plt.plot([0, 10000], [100, 100], 'k-', lw=2) | |
plt.text(950, 200, r'Scanlon', fontsize=8) | |
plt.plot([10000, 20000], [2000, 2000], 'k-', lw=2) | |
plt.text(12000, 2100, r'Doyle', fontsize=8) | |
plt.plot([20000, 30000], [2600, 2600], 'k-', lw=2) | |
plt.text(24000, 2700, r'Keyes', fontsize=8) | |
plt.plot([30000, 40000], [3100, 3100], 'k-', lw=2) | |
plt.text(34000, 3150, r'Binchy', fontsize=8) | |
plt.plot([40000, 50000], [3800, 3800], 'k-', lw=2) | |
plt.text(42000, 3850, r'Connoly', fontsize=8) |
Author
cavedave
commented
Oct 21, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment