Saturday, November 03, 2012

Hotelling's Law

Hotelling's Law is often cited as the reason politicians running against each other end up taking similar positions.  For example, look at Obama and Romney on this chart.  The classical example is two vendors selling ice cream to patrons along a boardwalk, where each patron will buy ice cream from the nearest vendor.  In this scenario, each vendor is incentivized to move right next to the other, towards the middle of the boardwalk, in order to maximize profit.

I started thinking about some extensions to this.  Namely, what happens if you add more vendors, and what happens in different spaces.  You might guess that if you add more vendors, they all cluster at the middle, but you would be wrong.

(I should add that I ran simulations but didn't work out any of the math, so it's possible some of my results here are not correct.)

Three Vendors
What happens with three vendors?  The middle vendor has no incentive to do anything and takes a random walk, but the outer vendors want to squeeze the middle one.  Once they all meet, they move around together, and don't necessarily stay at the center.

Four Vendors
It's tempting to think that four vendors would also fight over the same spot, but this did not happen in my simulations.  I instead got two vendors sitting right next to each other at 1/4, and the two others at 3/4.  Each vendor then gets 1/4 of the patrons, and none has any incentive to move.

N Vendors for Even N
This plays out just like four vendors, with two vendors at 1/N, two vendors at 3/N, two vendors at 5/N, etc., with each vendors getting 1/N of the patrons.

N Vendors for Odd N
This seems pretty chaotic.  I can't come up with any simple way to describe what happens, and it's not always the same.

Two Vendors, Circular Boardwalk
Now imagine a circular boardwalk.  In this scenario the vendors' positions do not matter at all, as they will split the profits equally.

Three Vendors, Circular Boardwalk
Eventually, you get a stable situation where two vendors are right next to each other serving 1/4 of the patrons each, and the other vendor is on the other side of the circle serving the other 1/2 of the patrons.

N Vendors for Even N, Circular Boardwalk
Plays out just like it does on a linear boardwalk, with pairs of vendors at N/2 equally spaced positions on the circle.

Two Vendors, Two Dimensions
Just like in one dimension, they move to the center.

Two Vendors on a Sphere
Same as a circle, position doesn't matter.

If I get a chance I'll try to get some of these simulations running on the web somewhere.  Also, someone please address this more rigorously than I just did.

Thursday, May 17, 2012

RescueTime productivity feedback

RescueTime is a useful tool for tracking your computer time, but it would be nice to get constant real-time feedback so you can see your scores plummet as you surf Facebook all day.

I hacked together a simple Windows application that lives in the system tray and shows your RescueTime productivity, updating every minute.  You can get it here.  You'll also need to install Python and PyWin32.  You also need to enable a RescueTime API key here and then add that key on line 16 of productivity_feedback.py.  If you want the application to run all the time, create a shortcut and set it as a startup task.

Yeah, I didn't make it easy for you.  If I get a chance I'll put together a simplified cross-platform version.