Blood caffeine concentration: part 2August 9th, 2014 · 5 min read
In a previous post, I mentioned that I’d integrate the formula so that coffee consumption could be considered an event of finite duration instead of a point event. Even if you bolt down a cup of coffee, it’s not instant. (If you really want to, you can use a Dirac delta function, also known as an impulse function, to model instant consumption. The following equations will still hold.)
I was going to simply integrate, but after rereading Animate Your Way to Glory I decided to derive it as a filter instead. This should come out to the exact same result, but with a method that’s a bit easier to grasp intuitively.
In the second demo, slide 66, the following equation appears:
This represents a convolved function, and as Wittens describes and demonstrates, convolution effectively “slides” one function along the mirror image of the other. In this case, is the filter and is the signal.
The unique thing about our application is that we’re not looking for a signal of similar magnitude to the input; we’re literally just summing events. Wittens says that the area under the curve for needs to equal 1, but in our case that’s not so.
Converting this from discrete events into a continuum is easy; just switch around the notation:
represents the output we want: the amount of caffeine in the body at time . is easy; that’s our consumption, or rate of input of coffee. For one cup consumed between time and , with being amount of caffeine in the cup:
Now, though, we must deal with the annoying fact that we don’t actually know what our filter is. Let’s derive it starting with our original formula.
That sigma is annoying; let’s convert it to an integral. Letting represent rate of caffeine consumption:
This is actually our answer, but I want to pick it apart a little bit before I call it a day. If you consider the consumption events used in our previous model as point events, you can model them with a Dirac delta function and the above formula still works.
And look, the terms stayed intact! Meaning that our filter is simply:
We can do one better though. If we define the following:
Then a cup of coffee containing amount of caffeine consumed between times and will, at time , cause the following amount of caffeine to remain in the body:
For multiple cups, we simply need to evaluate the above expression once for each cup. I don’t think we can really get any more accurate without a cup that constantly measures the level of liquid in it. Even if we tried this, it’s likely that the model would begin to break down. When you’re measuring on such small timescales, you’d need to keep track of things like esophagaus movement and salivation. Our model is about as good as it gets without delving into some of the crazier realms.