Wednesday, August 10, 2016

Numerical fun: tracking my blood caffeine level in one day

A few days ago, I decided to see what my blood caffeine profile looks like on a typical day. Since I didn't want to draw blood at regular intervals for analysis, I did the next best thing and tracked consumption and computed the blood level using a model of its dynamics.

Tracking consumption was simple: I have two french presses, both used for tea; the smaller one (1 liter) brews the caffeine equivalent of two espressos (80mg each, or 160 total) and the larger one (1.5 liter) brews the equivalent of three espressos (240mg). I just made a note of when I finished with one of the french presses and which it was.

To convert consumption into blood level, we need a state equation. We make the following assumptions:
  1. Caffeine level on wakeup is zero (an approximation).
  2. Time $t$ is discrete and measured in half-hours.
  3. Caffeine half-life in the body is two hours.*
The last assumption gives the equation

$\qquad L(t) = c(t) + 0.8409 \times L(t-1)$

where $L(t)$ is the level and $c(t)$ is the consumption at time $t$. This equation is an exponential decay process with a half-life of two hours: for a given $t=T$, assuming no consumption,

$\qquad L(T+4) = (0.8409)^4 \times L(T) = 0.5000 \times L(T)$.

(Two hours is 4 half-hours, since we're using the half-hour as the time unit.)

Putting the consumption and the initial condition into the equation and graphing it on a scale for the day in question we get

My average level was a bit high, but I'm used to it.

-- -- -- --
* I got this number from a doctor, but several sources have told me it's too low. Online sources point to a half-life of 3-6 hours. This changes the coefficient for $L(t-1)$ in the equation above to somewhere between 0.8909 (for three hours) to  0.9439 (for six hours). Possibly there's an update to this post in the future to deal with that.

Update in the future: I did the computations (click to embiggen):

Corrected Caffeine Level Profile