4 ms·
Show HN: Interactive: Visualizing Caffeine Halflives and Bedtime
- eli-bryan 6y agoI've never been a great sleeper. I knew caffeine could be a factor and I understood, at least intellectually, that caffeine’s half-life clearance meant that some of it might still be floating around my brain later in the day. But I didn't fully grok the dynamics until seeing it play out visually. So this is a (simple) simulator, built to visually explore 2 questions: 1. How long can caffeine stay in your system? 2. When will caffeine levels fall back below a threshold with minimal sleep disruption? The answer is, it depends... so I parameterized the notebook to try different options. Notes on the parameters / lessons learned are here: https://towardsdatascience.com/interactive-visualizing-caffeine-bedtime-4c256d562193 https://towardsdatascience.com/interactive-visualizing-caffe... Take this with a big grain of salt. I'm not a pharmacist, physician, chemist, etc, and this hasn't been reviewed by one. But at least for me, being able to turn the dials on a simple half-life model and see the consequences has been eye-opening. Default params are chosen based on: * https://www.ncbi.nlm.nih.gov/books/NBK223808/ https://www.ncbi.nlm.nih.gov/books/NBK223808/ * https://doi.org/10.1038/clpt.1987.126 https://doi.org/10.1038/clpt.1987.126 * https://doi.org/10.1002/cpt197824140 https://doi.org/10.1002/cpt197824140 * https://doi.org/10.5664/jcsm.3170 https://doi.org/10.5664/jcsm.3170 * https://doi.org/10.1111/j.1365-2869.2006.00518.x https://doi.org/10.1111/j.1365-2869.2006.00518.x * https://doi.org/10.1016/0006-8993(95)00040-W https://doi.org/10.1016/0006-8993(95)00040-W
- etothepii 6y agoAre these defaults close to accurate? I've pretty much stopped drinking coffee and think I may have noticed a general improvement.
- eli-bryan 6y agoThe defaults are based on published papers, but should be interpreted loosely given the variability. A few considerations: 1. Even though some companies list precise #s for caffeine content, actual caffeine content can vary widely from day to day (259mg - 564mg) according to [1] 2. Caffeine half life varies from person to person, from ~1.5 to ~9.5 hours. So 5 is typical according to [2], but unless you're a smoker or on certain birth control I haven't found anything yet to say which end of the distribution to expect for yourself. 3. Caffeine sensitivity also seems to vary from person to person. And the "sleep threshold" is more of an upper bounds than a target, based on working backwards to figure out how much caffeine subjects had in their system and still saw sleep disruption in [3,4,5]. So participants in [5] slept worse when you'd expect them to have ~25mg of caffeine remaining in their system on avg, but that doesn't necessarily mean they'd have slept normally at 24mg. These are covered in a bit more detail in the writeup: https://towardsdatascience.com/interactive-visualizing-caffeine-bedtime-4c256d562193 https://towardsdatascience.com/interactive-visualizing-caffe... [1] https://doi.org/10.1093/jat/27.7.520 https://doi.org/10.1093/jat/27.7.520 [2] https://www.ncbi.nlm.nih.gov/books/NBK223808/ https://www.ncbi.nlm.nih.gov/books/NBK223808/ [3] https://doi.org/10.5664/jcsm.3170 https://doi.org/10.5664/jcsm.3170 [4] https://doi.org/10.1111/j.1365-2869.2006.00518.x https://doi.org/10.1111/j.1365-2869.2006.00518.x [5] https://doi.org/10.1016/0006-8993(95)00040-W https://doi.org/10.1016/0006-8993(95)00040-W
- helph67 6y agoUsed to suffer occasional dizzy spells totally preventing me moving normally. A doctor said another patient removed caffeine from her diet, problem solved! I did same and each subsequent event was weaker, until now disappeared. List of food and drinks containing it here... https://www.nutrientsreview.com/articles/caffeine.html https://www.nutrientsreview.com/articles/caffeine.html
- quickthrower2 6y agoMy coffee habit caused a numeric overflow by the looks of it.
- eli-bryan 6y agoYikes! I'd assumed you might reach toxicity before running out of digits! If you post the "share" link from the notebook I'll take a look. Or feel free to email me, my address is in my profile.
- quickthrower2 6y agoTo reproduce: load the defaults then click the 8:00am plus button Once: you might expect restful sleep after 5am Twice: you might expect restful sleep after 6am Three: you might expect restful sleep after 12am But 12am (midnight) is before 5am :-), so I assume it overflowed, or it means 12pm (the following day).