Skip to content

Instantly share code, notes, and snippets.

@jamesmaa
Created February 7, 2018 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmaa/21c4789434b29ae5fc522b0d38414ae6 to your computer and use it in GitHub Desktop.
Save jamesmaa/21c4789434b29ae5fc522b0d38414ae6 to your computer and use it in GitHub Desktop.
Raymond Birthday Moving Average
birthdays = [date(year=1990+x, month=2, day=18) for x in range(5000)]
def avg(birthdays):
return float(len(birthdays)) / len([b for b in birthdays if b.weekday() == 6])
moving_avg = [avg(birthdays[:x]) for x in range(1, 5000)]
plt.plot(moving_avg)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment