Showing posts with label Math. Show all posts
Showing posts with label Math. Show all posts

Wednesday, July 24, 2013

Baby Sleeping Stats

The first few days after Cayman was born, he seemed to sleep and eat at random intervals. After a few sleepless nights of waking up for feedings, I started to wonder if there were patterns to when he was hungry and when he was tired. Shelley started keeping track of three behaviors: awake, sleeping, and eating. I put the behaviors into Excel and a month later we had this:




Close Up:
 

In the plots above, blue represents sleep, orange represents feeding time, and green awake time. Each column represents one day.

When we first started tracking him at a week old, the left side of the graph, we saw an unpredictable schedule filled with late night feedings and awake time. We certainly had a more ideal schedule in mind. We thought if we slowly worked at it, a schedule compromise between his schedule and our ideal schedule could be achieved. We calculated his average sleep requirement and noticed better nights (more sleeping) were associated with awake time from 6:00 to 9:00 PM. However, awake time from 6:00 to 9:00 PM was associated with sleep time from 3:00 to 6:00 PM, and so on (a butterfly/domino affect). We decided we would focus on trying to keep him awake from 6:00 to 9:00 PM and encouraging him to sleep from 3:00 to 6:00 PM. For the most part this worked as shown by the right half of graph. The green band near the bottom right half of the graph represents awake time from 6:00 to 9:00 PM. As of now, Cayman wakes up once per night for a feeding and quickly falls back asleep.

Cayman's sleep pattern is shown below. He averages 15 hours, 20 minutes, and 12 seconds of sleep a day with a standard deviation of 1.54 hours. This means there is lots of variation in his sleep where he sometimes sleeps around 14 hours and sometimes around 17.5 hours. As the plot below shows he tends to alternate between a low sleep day than a high sleep day. In fact, he has very little moderate sleep days; he seems to like the extremes.



More valuable to us is when he is sleeping. Ideally, we would like him to sleep as much as possible when we are sleeping from 9:30 PM to 8:00 AM (we don't sleep this entire period, but we would like to option to). When looking at the proportion of time he sleeps during the 9:30 PM to 8:00 AM period, we get the the plot below.



The lowest dot represents a night when Cayman only slept for 50% of the time between 9:30 PM to 8:00 AM. The highest dot represents our best night of sleep when Cayman slept about 97% of the night. The orange line is the linear regression (least squares) trendline and shows that overtime, the proportion of time he is sleeping between 9:30 PM to 8:00 AM is increasing. If the trend continues, we can expect him to sleep an additional 3.78 minutes each night.  

Saturday, May 25, 2013

Weddings vs. Births

Our baby is due June 13th. June 13th is right in the middle of wedding season. In fact, I am DJ'ing many weddings near the due date including: May 25, June 1, June 8, June 15, and June 22. May 25th is today, and Shelley is shopping,  so labor seems unlikely (but not impossible). That leaves four weddings that could potentially overlap with Shelley's labor. The worse case scenario is if Shelley goes into labor on a Friday night or Saturday morning before a wedding. I was curious of the probability of this happening and since school is out and I already miss Statistics, I investigated it.
Births relative to due dates are approximately normally distributed with a standard deviation of 10 days. Using excel, I found which dates correlated to the day before and the day of a wedding and converted these intervals to z-scores.

x z
26-May-13 -18 -1.8
27-May-13 -17 -1.7
28-May-13 -16 -1.6
29-May-13 -15 -1.5
30-May-13 -14 -1.4
31-May-13 -13 -1.3
1-Jun-13 -12 -1.2
2-Jun-13 -11 -1.1
3-Jun-13 -10 -1
4-Jun-13 -9 -0.9
5-Jun-13 -8 -0.8
6-Jun-13 -7 -0.7
7-Jun-13 -6 -0.6
8-Jun-13 -5 -0.5
9-Jun-13 -4 -0.4
10-Jun-13 -3 -0.3
11-Jun-13 -2 -0.2
12-Jun-13 -1 -0.1
13-Jun-13 0 0
14-Jun-13 1 0.1
15-Jun-13 2 0.2
16-Jun-13 3 0.3
17-Jun-13 4 0.4
18-Jun-13 5 0.5
19-Jun-13 6 0.6
20-Jun-13 7 0.7
21-Jun-13 8 0.8
22-Jun-13 9 0.9
Next, using R, I graphed the probability density function. The area under the entire curve is 1 and the the sum of the shaded regions corresponds to the probability the birth will happen during the intervals that correspond with the weddings.





Using R again, I calculated these probabilities.
> pnorm(-1.2,mean=0,sd=1)-pnorm(-1.3,mean=0,sd=1)
[1] 0.01826919
> pnorm(-.5,mean=0,sd=1)-pnorm(-.6,mean=0,sd=1)
[1] 0.03428442
> pnorm(.3,mean=0,sd=1)-pnorm(.2,mean=0,sd=1)
[1] 0.03865171
> pnorm(.9,mean=0,sd=1)-pnorm(.8,mean=0,sd=1)
[1] 0.02779527

It appears there is an approximately, 11.9% chance the baby will be born while I am working a wedding. This probability represents an uncommon but not rare event, but it is a conservative estimate. DJ'ing a wedding is really about an on-site 8 hour commitment and the probability calculates for a 48 hour interval for each wedding. This means there is less than a 11.9% chance the baby will be born while I am working a wedding. Additionally, even if the 11.9% is accurate, there is an 88.1% chance the baby will not be born during a wedding. 

Friday, May 25, 2012

Shelley & Kendall get Master's Degrees

The years 2010 through 2012 were busy for Shelley and I. We both completed Master's degrees from California State University Northridge (CSUN). On May 24, 2012, I was honored to speak at my hooding ceremony with another Master's candidate.

 Shelley and I with our Master's hoods. 

 Speaking at the hooding ceremony with Buckley Mitchell. 

 
My good friend and colleague Robert Hammell. He helped get me through the program.