Tuesday, November 28, 2017

Null is a Global Variable

Programmers often bemoan the problems of the concept of null that exists in programming languages. Even C.A.R. Hoare, the inventor of the null reference, calls it a billion dollar mistake. Some detest its existence, and indicate that it's useless. However, it occurred to me that null can actually be thought of as a global variable - one that is used across all applications and domains to indicate special cases, such as the end of a data structure or a missing entry.

Monday, October 30, 2017

Oft-Misheard Phrases in the Workplace

There's an affliction that affects many millions of Americans in the workplace, and it's time to bring that affliction to light. There's perhaps nothing more benignly embarrassing than uttering one of these often misheard phrases during a work meeting, much less writing them down in a widely distributed email or memo. Perhaps it's time to set things straight once and for all, and help bring our less fortunate colleagues out of the darkness by setting them on the righteous path to using the correct version of these phrases.

Which version of each of these phrases do you think is the correct one?

Friday, February 3, 2017

The Math Behind the Jury Selection Problem

I recently served on the jury for a trial in the county superior court system, and contrary to popular belief it turned out to be an interesting experience. The ordeal gave me confidence in the idea of being judged by a jury of one's peers, and I came away with an appreciation of the fact that the responsibilities of a jury are precise and straightforward, much like the role of computer hardware (jurors) carrying out the instructions of a software program (law) given a set of well-defined inputs (evidence).

As I sat through the initial jury selection process, I also got to thinking about some of the mathematics behind the process. In particular, is there a way to answer the two questions on every prospective juror's mind: will I be selected as a juror and how long is this process going to take?

Tuesday, March 8, 2016

Wheel of Fortune Mystery Wedge Problem

The Wheel of Fortune Mystery Wedge Problem is my attempt at a slightly more modern spin (pun intended) on the classic Monty Hall problem, which is a probability puzzle based on an older game show. Most modern American (and many international, so I've learned) TV viewers are likely familiar with Wheel of Fortune, but this specific problem can be framed in a way that doesn't require complete knowledge of the rules of the game:

  • You have X dollars in the bank and it's your turn to spin the wheel
  • You spin the wheel and land on the $10,000 Mystery Wedge, make a correct guess to win Y dollars, and Pat Sajak, the host, then offers you two options:
  • The first option is to do nothing. It is still your turn and you will end up with X + Y dollars in the bank.
  • The second option is to flip over the Mystery Wedge for a 50/50 shot at winning $10,000. If you lose, you lose all your money plus your turn.

Should you flip over the Mystery Wedge or not? At what values of X and Y should you flip the wedge and take the risk?

Saturday, December 12, 2015

California Drought Dashboard

The drought in California has been going on for a few years now, and the talk of an El NiƱo winter bringing much needed relief makes me wonder about the latest state of the drought situation as we move through a hopefully wet winter. Surprisingly, I was hard-pressed to find good, up-to-date sources of California drought conditions data that show changes over time.

For starters, the United States Drought Monitor provides great percentile data for different drought level intensities, updated on a weekly basis. However, the tables do a poor job of depicting the progression of the drought conditions on a weekly basis, even though that data is readily available and dates all the way back to 2000. The best visualization of this data that I've found, in time-series form, is the graph from the US Drought Monitor that almost gets the job done but lacks some fine grained control. So, I made a slightly tweaked version of this graph that is hopefully a solid dashboard that can serve as an up-to-date summary of drought conditions. The graph can be easily manipulated for comparisons over different time periods, and always loads the latest data from the aforementioned sources.

Sunday, March 10, 2013

Yelp is to Netflix as Foursquare is to Netflix

Pop quiz, hot shot. Here's an SAT-style analogy question for you. Yelp is to Netflix as Foursquare is to what? Answer: Netflix. To be precise, Yelp is to Netflix DVD as Foursquare is to Netflix Streaming. The reason for that is data.

Thursday, February 21, 2013

Winning Bar Bets With Mathematics

Benford's law is pretty neat. I first came across this phenomenon while watching a silly Internet TV show related to bar bets. The bar bet that exploits Benford's law is a little complicated, and relies (of course) on the law of large numbers.

The premise is that you challenge your fellow bar patrons to a bet: that humans are no good at generating random numbers. It makes sense intuitively since people tend to pick numbers that have a special meaning, and there's a finite number of numbers that have meaningful connotations (i.e. 3's a charm, lucky number 7, etc.). To add to the challenge, you'll throw in some randomness. Each person will come up with two randomly chosen quantities based on some data, such as the population of pet birds in the US and the volume of water in the Dead Sea in cubic feet. Then, multiply the two numbers to get a third number. The bet will be that even the first digit of *that* number is not uniformly distributed. On the surface, it seems counter-intuitive. But Benford's law will give you an edge in this silly bar game.