‹ Writings

🧠 Musings

Murphy’s Law and the Metropolis Algorithm


A few weeks ago I found myself writing a note to self about how many happenings in life the last few months seemed like Murphy’s Law at play. I went on to note how I always feel suspicious at the end of a “good week”, since things are almost always too good to be true. Surely life can’t be this easy right? What’s the plotline for this episode?

However, two things happened in the weeks that followed that may have increased my appreciation for Murphy’s Law.

First, I finished reading Algorithms to Live By and feel somewhat enlightened. This epiphany largely stems from the book’s chapter on optimization. Which by the way is a fantastic book. I don’t know if I have the mental energy to write a review, but it’s a delightful read if you're familiar with some practical computer science concepts. I don’t even recommend it as some kind of productivity handbook, it’s just fun!

Second, I wrapped up a months long project I’ve been working on with the Michigan Solar Car Team. Here, I developed a stochastic optimization algorithm that somewhat beats historically unbeaten algorithms Yes, I'm still running on the high of knowing I beat some fancy mathematical solutions with... (guided) randomness. .

I guess both activities are pretty related since they concern computer wizardry. And it turns out that computer wizardry can teach us a thing or two about life, namely how Murphy’s Law and the Metropolis Algorithm (I’m going to call this principle MLM) may work together to make life better.

Murphy’s Law is really just an encapsulation of the role of chaos in our lives. Chaos plays an important role in optimization algorithms too. Some algorithms’ use of randomness and heuristics can compound into converging at a local optimum. To prevent this, sprinkling in chaos with an accounted cost can help explore new search spaces which may lead to other optima.

Similarly, chaos in real life may introduce problems with a cost — nobody likes to have a good week ruined. But what if that good week may have been some kind of local optimum?

Life as a hill-climbing optimization problem. There has to be some poetic title for this graph that's a combination of "the pursuit of happiness", "for hills to climb", and "the game of life". Also the graph would have dozens of independent axes in real life, but I can't draw that.

By being nudged in a bad direction, we may be forced to explore a path that seemed bad initially, but improves with activity and changes. And who knows, that path may lead us to a better, and maybe even global, optimum! (whether a global optimum exists in the Game of Life is a question for the professional philosophers out there)

In short, trying and accepting worseness along the way to possibly lead to something even better is what the Metropolis Algorithm recommends. And Murphy’s Law can be the worseness generator.

But truthfully we don’t know what our life vs goodness function truly looks like. It seems like accepting the role of chaos and embracing the potential for bad things to become good things is a good recipe to maintain your sanity though.

So it seems like the conclusion is: accept MLM into your life… and you too can be rich some day?

~ Amal