• Histogram of hours slept (AP Stats)
    Histogram of hours slept (AP Stats)
  • Probability plot of hours slept (AP Stats)
    Probability plot of hours slept (AP Stats)

Back in highschool

This project began during my junior year of high school. My AP Statistics teacher wanted us to apply what we learned in class to something relevant in our lives. I had recently gotten a Fitbit, so it was the natural choice for me to analyze my sleep data.

I think wearable sensing is a really awesome application for monitoring health. It is an opportunity ripe for gameification.

When I submitted my initial project, I was only investigating if the amount of hours I slept followed a normal distribution. It looked pretty dang close with only 50 samples, considering the linear trend of the probability plot.

“Why we sleep”

I read this book during my freshman year of college. This really ignited my interest in sleep and made me realize its importance. Getting enough sleep is one of the simplest ways we can improve out health. There is no bodily function that sleep doesn’t affect. And from my own experience, quality of life goes through the roof when I feel rested and awake. I could experience the best day of my life, but as long as I was tired, it would have felt awful.

What is my optimal bedtime?

I spent a significant amount of time pondering how I would go about this. There are so many factors that affect the quality of sleep like temperature, diet, exercise, time of day, and more. Some of those I do have control over, but it would be incredibly difficult to collect a dataset. I would be conducting an experiment on myself for months.

One option was to wake up and go to bed based on a random number generator for several months. That would have been awful, so I searched for another method.

I could have experimented with the factors listed above, but they aren’t, in my opinion, the things I can control. Here is what I attempted to analyze:

  1. What time I go to bed
  2. What time I wake up

I decided to take a bayesian approach. Given that I go to bed at time $N$, what is the probability that I get $H$ hours of sleep while waking up at $M$ time. This will be more clear with a graph.

$$P(\ge H \mid \text{(M wakeup and N bedtime)})$$

Example $P(\ge7.5 \mid \text{(Wakeup: 8am, Bedtime N)})$

Probability of getting enough sleep if I wake up at 8 AM
Probability of getting enough sleep if I wake up at 8 AM

On the x-axis is the time I go to sleep (in military time). While on the y-axis is the probability of getting $\ge 7.5$ hours of sleep. The orange line represents a specific wake up time, 8 AM. So let’s say I go to bed at 11 PM (23:00), then I have approximately an 80% chance of getting $\ge 7.5$ hours of sleep.

The probability approaching 0 as it gets closer to midnight seems to validate that my code works. Clearly if I go to bed at 1 am, there is absolutely no chance I get 7.5 hours since there aren’t even 7.5 hours between 1 am and 8 am.

Now you might see something strange. If I’m waking up at 8 am, shouldn’t I have had 0% at 1 am and not midnight? The graph is dropping off way too steeply.

My best explanation is because we aren’t perfectly efficient sleepers. Every minute spent in bed is not necessarily time that we are asleep. On average, according to Fitbit, users are awake during the night for 25 minutes. This is also dependent on age. For my age range, it is normal to be awake for 5-15% of the night. My statistic on average is 9-10%. So for me to get 7.5 hours of sleep, I need to be in bed for at least 8.25 hours.

Applying to all possible wake up times

For all wake up times
For all wake up times
When I saw this graph, I became very excited!

According to “Why we sleep”, generally a young adult has a biologically need to have a later bed time. And like many others, I would love to stay up late and wake up late, but the college schedule does not necessarily support that. It’s even worse with middle and high school where you have to wake up at 6 AM.

So for the longest time, I faced my reality and forced myself to go to bed earlier. However, I had the suspicion that by going to bed later, I actually fell asleep faster. The effects are more pronounced

Sleep Analysis

Inducted January 31, 2023

jupyter python data-science

A statistical analysis of sleep records from a Fitbit