Skip to content

Instantly share code, notes, and snippets.

@cavedave
Created September 15, 2025 19:54
Show Gist options
  • Save cavedave/8ecc83b5bc42f3e34c55690349e6cb2f to your computer and use it in GitHub Desktop.
Save cavedave/8ecc83b5bc42f3e34c55690349e6cb2f to your computer and use it in GitHub Desktop.
Neil Young Age
import numpy as np
import matplotlib.pyplot as plt
# People (first name, birth year)
people = [
("Neil", 1945),
("Paul", 1956),
("Angus", 1955),
("Sean", 1959),
("Esme", 1949),
("Will", 1979),
]
start_year, end_year = 1940, 2025
years = np.arange(start_year, end_year + 1)
def young_accuracy_by_year(years, birth_year, cutoff_age=30, steepness=0.25):
ages = years - birth_year
acc = 1 / (1 + np.exp(steepness * (ages - cutoff_age)))
acc[ages < 0] = np.nan
return acc
plt.figure(figsize=(10.5, 6))
for name, b in people:
acc = young_accuracy_by_year(years, b, cutoff_age=30, steepness=0.25)
plt.plot(years, acc, linewidth=2, label=name)
plt.xlim(start_year, end_year)
plt.ylim(-0.05, 1.05)
plt.xlabel("Year", fontsize=18)
plt.ylabel("Accuracy", fontsize=18)
plt.title("Accuracy of \"Young\" Surname", fontsize=25)
plt.legend(ncol=3, fontsize=15, frameon=False)
plt.tight_layout()
# Add annotation
plt.text(0.95, -0.081, 'by @iamreddave', fontsize=8, color='gray', ha='right', transform=plt.gca().transAxes, alpha=0.7)
out_path = "young_curves_firstnames.png"
plt.savefig(out_path, dpi=150)
plt
out_path
@cavedave
Copy link
Author

young_curves_firstnames (3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment