Skip to content

Instantly share code, notes, and snippets.

@stucchio
Created November 29, 2011 02:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stucchio/1403042 to your computer and use it in GitHub Desktop.
Save stucchio/1403042 to your computer and use it in GitHub Desktop.
Graphs of bodyweight vs time
from pylab import *
E = 1.5 # exercise level
height = 6*12 #Height in inches
a = E * (66 + 12.7*height) / 3500.0
b = E * 6.23 / 3500
g = E * 6.775 / (365*3500.0)
age_range = (28, 40)
t = arange(age_range[0]*365,age_range[1]*365)
def base_weight(consumption, t):
consumption = consumption/3500.0
return ((consumption-a)*b+b*g*t-g)/(b**2)
print base_weight(3000, 25*365)
def w(t, consumption, initial_weight):
c = initial_weight - base_weight(consumption, t)
return base_weight(consumption, t) + c * exp(-b*(t-t[0]))
plot(t, base_weight(3500, t), label="Perfect Balance, 3500 cals")
plot(t, base_weight(3000, t), label="Perfect Balance, 3000 cals")
plot(t, w(t, 3500, base_weight(3000, t)), label="Paula Deen Fan")
plot(t, w(t, 3000, base_weight(3000, t)), label="Alton Brown Fan")
xlabel("Age (years)")
xticks( [ tt*365 for tt in arange(age_range[0], age_range[1]+1) ], [ tt for tt in arange(age_range[0], age_range[1]+1)] )
ylabel("Bodyweight (lbs)")
legend()
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment