Category Archives: research

Formula for happiness

The formula for happiness turns out to be 0.67 + 0.09 * sin(0.93t), who would have thought it was so simple?

At least that is what you get if you put my personal mood data from Affect Sampler through the free-as-in-beer download of Eureqa. This is a workbench that applies the techniques from Hod Lipson’s “Distilling Free-Form Natural Laws from Experimental Data” paper, using genetic programming to find parsimonious functional forms for arbitrary data.

I was really impressed with how quick and easy it was to set up and find something reasonable. While the fit is far from great on my toy emotion tracking test, with just a few weeks’ data (surprisingly, my moods are not exactly periodic!) it does seem to have found a something approaching a valid pattern. With t measured in days, 2*PI/0.93 = 6.75 which is close to seven. It looks to me like it is trying to fit a weekly rhythm, which seems plausible enough.

Eureqa screenshot

Screenshot from Eureqa software fitting Affect Sampler data

What do you think?

Solving Sudoku with L1-norm minimization

I came across an interesting paper by Babu, Pelckmans, Stoica the other day, via my favourite Compressed Sensing blog Nuit Blanche.

The idea is that it is possible to formulate Sudoku as a linear system, with the board as a 9x9x9 indicator vector and the rules as a matrix encoding the different Sudoku constraints. The solution to this system with the minimal L1-norm will often be an indicator vector as well – and will represent the solution to the puzzle with the missing entries completed.

To play around with the ideas here I re-implemented the paper in Python, using CVXOPT. I’m going to try and explain all this coherently at the December London Python Dojo meetup

Update: I’ve now updated the code with the help of the much-easier-to-use CVXMOD wrapper library, and put it on GitHub here if you want to play with it.

The original authors’ Matlab codes are available as well.

Android experience sampling update

I’ve updated the Affect Sampler code on GitHub recently. If you want to play with it, it now has:

  • A downloadable .APK file you can use to install it to your phone
  • A hosted web service you can sync your data to, with a Google account
  • The ability to make graphs of your mood on the phone

You can also export the data from the web service, to load into something like Timetric.

There’s lots more to do on this, but all you Android-toting self-tracking experimentalists can play with it now. Let me know if you do – I’d be happy to hear your thoughts. I’d also be happy to hear from anyone who wanted to use it as a data-gathering platform for experiments in psychology or similar…

(Thanks to @jhugman for his generous feedback!)

Experience sampling on Android

I’ve started writing a personal informatics application for Android phones to quickly record moods throughout the day, at random intervals – a technique which seems to be called Experience Sampling. It would work well with a service like, and I’m intending to add support for uploading to something like that soon.

The motivation is to make use of the rich data that comes from a smartphone to allow a bit of objective introspection into our own lives, to find out what actually makes us tick (a la Quantified Self). I’m intending to start with a mood diary, but then try to correlate this with other data streams that can be captured: my location, the weather; data from my bank balance and diary; perhaps diet or exercise habits.

The code is on github if you’re interested. It builds and runs on my HTC Hero now, but it’s pretty basic – when there are a few more features I might give it a proper licence and release it on Market if there’s interest.

Quantitative finance near the speed of light

Haug, Espen – WilmottWiki

“Space-time Finance, The Relativity Theory’s Implications for Mathematical Finance”