Saturday, January 14, 2017

How Often Does Friday the 13th Happen?

Background

So yesterday was Friday the 13th.

I hadn't even thought anything of it until someone mentioned it to me. They also pointed out that there are two Friday the 13ths this year: the one that occurred yesterday, and there will be another one in October.

This got me to thinking: how often does Friday the 13th usually occur? What's the most number of times it can occur in a year?

Sounds like questions for a nice little piece of everyday analytics.

Analysis

A simple Google search revealed over a list of all the Friday the 13ths from August, 2010 up until the end of 2050 over at timeanddate.com. It was a simple matter to plunk that into Excel and throw together some simple graphs.

So to answer the first question, how often does Friday the 13th usually occur?


It looks like the maximum number of times it can occur per year is 3 (those are the years Jason must have a heyday and things are really bad at Camp Crystal Lake) and the minimum is 1. So my hypothesis is:
a. it's not possible to have a year where a Friday the 13th doesn't occur, and 
b. Friday the 13th can't occur more than 3 times in a year, due to the way the Gregorian calendar works.

Of course, this is not proof, just evidence, as we are only looking at a small slice of data.

So what is the distribution of the number of unlucky days per year?


The majority of the years in the period have only one (18, or ~44%) but not by much, as nearly the same amount have 2 (17, or ~42%). Far less have 3 F13th's, only 6 (~15%). Again, this could just be an artifact of the interval of time chosen, but gives a good idea of what to expect overall.

Are certain months favoured at all, though? Does Jason's favourite day occur more frequently in certain months?


Actually it doesn't really appear so - they look to be spread pretty evenly across the months and we will see why this is the case below.

So, what if we want even more detail. When we say how frequently does Friday the 13th occur, and we mean how long is it between each occurrence of Friday the 13th? Well, that's something we can plot over the 41-year period just by doing a simple subtraction and plotting the result.


Clearly, there is periodicity and some kind of cycle to the occurrence of Friday the 13th, as we see repeated peaks at what looks like 420 days and also at around 30 days on the low end. This is not surprising, if you think about how the calendar works, leap years, etc. 

If we pivot on the number of days and plot the result, we don't even get a distribution that is spread out evenly or anything like that; there are only 7 distinct intervals between Friday the 13ths during the period examined:


So basically, depending on the year, the shortest time between successive Friday the 13ths will be 28 days, and the greatest will be 427 (about a year and two months), but usually it is somewhere in-between at around either three, six, or eight months. It's also worth noting that every interval is divisible by seven; this should not be surprising at all either, for obvious reasons.

Conclusion

Overall and neat little bit of simple analysis. Of course, this is just how I typically think about things, by looking at data first. I know that in this case, the occurrence of things like Friday the 13th (or say, holidays that fall on a certain day of week or the like) are related to the properties of the Gregorian calendar and follow a pattern that you could write specific rules around if you took the time to sit down and work it all out (which is exactly what some Wikipedians have done in the article on Friday the 13th).

I'm not a superstitious, but now I know when those unlucky days are coming up and so do you... and when it's time to have a movie marathon with everyone's favourite horror villain who wears a hockey mask.

Monday, January 9, 2017

Top 100 CEOs in Canada by Salary 2008-2015, Visualized

I thought it'd been a while since I'd some good visualization work with Tableau, and noticed that this report from the Canadian Centre on Policy Alternatives was garnering a lot of attention in the news.

However, most of the articles about the report did not have any graphs and simply restated data from it in narrative to put it in context, and I found the visualizations within the report itself to be a little lacking in detail. It wasn't a huge amount of work to extract the data from the report and quickly throw it into Tableau, and put together a cohesive picture using the Stories feature (best viewed on Desktop at 1024x768 and above).

See below for the details, it's pretty staggering, even for some of the bottom earners. To put things in context, the top earner had $183M a year all-in, which, if you work 45 hours a week and only take two weeks of vacation per year, translates to about $81,000 and hour.

Geez, Looks like I need to get into a new line of work.