iTunes U podcasts on Android

In the giant ledger that weighs up the pros and cons of the Internet for humanity, one of the unalloyed virtues is the easy availability of world class lecture series you can watch or hear for free.

(Thank you especially to Stanford, I’ve enjoyed relativity and convex optimization recently, as well as Andrew Ng’s machine learning course.)

Recently I’ve been interested in game theory, but annoyingly the Yale site only gives an iTunes U link like this:

http://deimos3.apple.com/WebObjects/Core.woa/Browse/yale.edu-dz.2821770593

But I don’t have an iPod, do I have to mess around with hulking great mp3 files separately? Ah-ha, no. You can change “Browse” to “Feed” like this in the URL to get an RSS feed:

http://deimos3.apple.com/WebObjects/Core.woa/Feed/yale.edu-dz.2821770593

… which you can subscribe to with Google Listen.

I like to use a URL shortener such as bit.ly to save me typing all that into my phone, getting it down to http://bit.ly/fcJQuz.

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 your.flowing.data, 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.

Energy and the economy

Via FT Alphaville an interesting but scary article on Energy is everything by Michael Lardelli.

He considers the embedded energy value of each dollar and looks at the world economy in terms of money supply as well as in energy production terms. His thesis is that the world economy has actually been contracting since 2005, as net energy output falls – economic growth since then was effectively a monetary illusion.

So if economic growth is energy constrained, why doesn’t the price of oil go up, incentivizing energy producers to extract more and increase energy output? Lardelli argues that as we use up easily available resources the remaining energy supplies themselves require more energy to extract. Energy becomes simultaneously scarce and unprofitable.

Once energy is in decline the recent pervasive economic lie that everyone can become wealthier can no longer be sustained. Now one person’s increased wealth can only come at the expense of another person’s worsened poverty. Actually, it is worse than a zero sum game since the economy is not just failing to grow – it is actually contracting at the same time as the number of consumers (population) is expanding.

So now what do we do?

(Reminds me of the ideas in novel The Burning by Thomas Legendre.)

Multiple modes for mxml and Actionscript in Emacs

Flexing in Emacs again… Emacs 22 supports the entertainingly named MuMaMo mode which allows support for Multiple Major Modes. This is useful for editing MXML files that mix XML markup with Actionscript.

I am using MuMaMo together with actionscript-mode and nxml-mode with this definition in my .emacs:

(defun mumamo-chunk-mxml-script (pos min max)
"Find ... , return range and actionscript-mode."
(mumamo-quick-static-chunk pos min max "" "" nil 'actionscript-mode nil))

(define-mumamo-multi-major-mode mxml-actionscript-mumamo-mode
"Turn on multiple major modes for MXML files with main mode `nxml-mode'.
This covers inlined Actionscript."
("MXML Actionscript Family" nxml-mode
(mumamo-chunk-mxml-script
)))

(add-to-list 'auto-mode-alist '("\\.mxml$" . mxml-actionscript-mumamo))

Strange paths

Don’t read this blog, go and read Strange Paths instead. Beautiful animations and discussion on aspects of “Physics, computation, philosophy”.

Non-negative matrix factorization and music

Amongst the work I did during the EASy MSc at Sussex was this 2005 paper on non-negative matrix factorization (NMF) applied to sound analysis.

I’d become fascinated with the information theoretic ideas about perception and redundancy originated by people like Horace Barlow, and particularly their application to sound by researchers like Paris Smaragdis. I’d originally been interested in ICA but Smaragdis and others were starting to apply NMF to sound around that time.

The basic idea of the paper is: the brain is able to analyze distinct sounds from the jumbled mixture that hits our eardrums because audio signals generally have structure, musical audio particularly so. If you take a time-frequency transform like a spectrogram of a piece of piano music, you find that it has approximately:

  • A sparse representation: each note has a characteristic frequency profile. The complete spectrogram is made by scaling and adding all the notes playing simultaneously. In the bases of all these profiles, the sparse representation consists of the activation levels of each notes.
  • Scaling invariants: scaling a vibrating system physically up or down is equivalent to translation in log-frequency.

NMF is a way of obtaining a low-rank approximation of a matrix as a product of two others, subject to the constraint that all the elements have to be positive of zero. Amazingly, this simple assumption is enough to discover all kinds of useful structure, including the separation into spectral bases like that in a spectrogram.

Left to its own devices, straight NMF on the piano spectrogram piece would likely approximate the spectral profiles of each note, but in no particular order. The additional step in this paper is to further require there to be only one profile, log-frequency translated – and this is indeed enough to get you recognizable notes.

There is an enormous and booming literature on sparsity in signal processing in areas like compressed sensing – Nuit Blanche blog is a good place to find out more.

Evolutionary and Adaptive Systems

Synchronicity… a sudden convergence of interesting links have got me all nostalgic.

It all sent me back to the fascinating year I spent in 2004/05 doing the Evolutionary and Adaptive Systems MSc at the University of Sussex.

This wonderful inter-disciplinary course brings together researchers in computer science, biology, creative systems and even a little philosophy. Pretty much everything was fair game for study, from robot ants spreading glow in the dark pheromone trails; neural networks made of actual buckets of water; to evolved passive-dynamic walking legs with fourteen knees.

I mean to go back through the work I did at Sussex and see what’s interesting enough to post here, starting with my dissertation on NMF.