Skip to content

Instantly share code, notes, and snippets.

@jameskyle
Last active August 29, 2015 13:59
Show Gist options
  • Save jameskyle/10752595 to your computer and use it in GitHub Desktop.
Save jameskyle/10752595 to your computer and use it in GitHub Desktop.
%matplotlib inline
from datetime import date, timedelta
RACE_DISTANCE = 200
CLIMBING_DISTANCE = 4219
RACE_DATE = date(2014, 7, 26)
RATE = 0.10
PERCENT_OF_TARGET = .80
TODAY = date.today()
def distance_regression(race_day, race_kilometers, label):
weeks = (race_day - TODAY).days / 7
target = race_kilometers * PERCENT_OF_TARGET
# Calculate how many kilometers to start with assuming
# the week before the race is a recovery week and a
# weekly increase of RATE until PERCENT_OF_TARGET distance
# is acheived.
initial_distance = target / ((1 + RATE)**(weeks - 1))
def distance(week):
return int(initial_distance * 1.10**week)
distances = map(distance, xrange(1, (weeks)))
for distance in distances:
print("Week {0} {1} Distance: {2}".format(distances.index(distance) + 1,
label,
distance))
distance_regression(RACE_DATE, RACE_DISTANCE, label="Total")
print("========================")
distance_regression(RACE_DATE, CLIMBING_DISTANCE, label="Climbing")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment