public
Created

Calculating the information the body receives over a lifetime

  • Download Gist
bodyInformation.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
def humanize_bytes(bytes, precision=1):
# taken from http://code.activestate.com/recipes/577081-humanized-representation-of-a-number-of-bytes/
abbrevs = (
(1<<60L, 'EB'),
(1<<50L, 'PB'),
(1<<40L, 'TB'),
(1<<30L, 'GB'),
(1<<20L, 'MB'),
(1<<10L, 'kB'),
(1, 'bytes')
)
if bytes == 1:
return '1 byte'
for factor, suffix in abbrevs:
if bytes >= factor:
break
return '%.*f %s' % (precision, bytes / factor, suffix)
 
age = 60
lifetime = age*365*24*60*60 # seconds we've been alive
 
rods = 120E6
cones = 7E6
 
eyeCells = rods+cones
eyeRefresh = 1/30 # 30 Hz
 
eyeDataRate = 10E6 # bits / second
eyesDataRate = eyeDataRate * 2 # we have two eyes
eyesDataRateBytes = eyesDataRate/8. # bits to bytes
humanizedEyes = humanize_bytes(eyesDataRateBytes)
print 'Eyes data rate is %s per second.' %humanizedEyes
 
earRate = 22E3 # 22 Khz is the maximum the ear can hear
earRate *= 2 # multiply by two to avoid sampling errors
earSensitivity = 2**16
earDataRate = earRate * earSensitivity # sampling rate * bits = data rate (bits/second)
 
earsDataRate = earDataRate * 2 # we have two ears
earsDataRateBytes = earsDataRate / 8.
humanizedEars = humanize_bytes(earsDataRateBytes)
print 'Ears data rate is %s per second.' %humanizedEars
 
# Now we want to add these up over a lifetime.
eyeData = lifetime * eyesDataRateBytes
humanizedTotalEyes = humanize_bytes(eyeData)
print 'over %s years, our eyes will transmit %s' %(age, humanizedTotalEyes)
 
earData = lifetime * earsDataRateBytes
humanizedTotalEars = humanize_bytes(earData)
print 'over %s years, our ears will transmit %s' %(age, humanizedTotalEars)
 
totalData = earData+eyeData
humanizedTotal = humanize_bytes(totalData)
print 'The total information we will receive will be upwards of... '
print '%s' %humanizedTotal

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.