Older blog entries for danstowell (starting at number 54)

python: combining interpolation with heatmaps

I saw Brandon Mechtley's splmap which is for plotting sound-pressure measurements on a map. He mentioned a problem: the default "heatmap" rendering you get in google maps is really a density estimate which combines the density of the points with their values. "I need to find a way to average rather than add" he says.

Just playing with this, here's my take on the situation. You don't average the values, you create some kind of interpolated overall map, but separately you also use the density of datapoints to decide how confident you are in your estimate at various points on the map. Python code is here and here's an example plot:

Dataviz folks might already have a name for this...

Syndicated 2013-04-16 10:33:02 (Updated 2013-04-16 10:42:43) from Dan Stowell

16 Apr 2013 (updated 17 Apr 2013 at 17:13 UTC) »

Sandwich of the week

The Little Woodford Cafe does a nice line in sandwiches. They often have a Sandwich Of The Week which adds variety. Here I'm just noting down some good ones they've done, for the purposes of sandwich-filling-inspiration:

  • Salmon, freshly-poached, with cucumber and a homemade tartare sauce
  • Tuna fiorentina (with boiled egg and spinach)
  • Christmas special (turkey, sausage, cranberry sauce, stuffing - oh my)

Syndicated 2013-04-16 09:14:36 (Updated 2013-04-17 12:59:53) from Dan Stowell

9 Apr 2013 (updated 10 Apr 2013 at 07:14 UTC) »

How many persons under trains on the tube, so far in 2013?

There seem to have been two separate person under a train incidents on the London underground today. I know nothing about either of them, but there was also one last Friday - and the cluster of events, well, first it made me feel awful, but then I wondered if there were any stats to help understand how common these events are.

Well yes there are. For example you can see some old-ish data for 1998-2005 here. I couldn't find any more recent data - you could file an FOI request if you like. BUT - TfL's twitter feeds tell the public whenever travel is disrupted. And since they use the standard form of words, it's quite simple to go through and find all occurrences, for example, for 2013 so far. So here they are:


Fifteen in total, so far for 2013. Roughly one per week. This is not the same type of data as the old data I linked above (it includes fatalities and nonfatalities, I expect, whereas the old data is just for the former).

You can do some basic statistical modelling on this: if you assume these are independent events and model them with a Poisson distribution, then you find the probability of seeing two-or-more incidents on one day is 1.04% - which essentially means there's nothing particularly weird about seeing it happen at some point over the past three-and-a-bit months.

Syndicated 2013-04-09 17:36:27 (Updated 2013-04-10 02:19:44) from Dan Stowell

29 Mar 2013 (updated 3 Apr 2013 at 13:11 UTC) »

Clementine cake

This clementine cake is lovely and juicy, with a nice sweet chewiness to the crust. And look at that crumb:

When I took the next photo I accidentally left the flash on - but it does show off some of the bright orange colouring in the cake:

It's an easy cake to make. Cos of the juiciness it doesn't keep for that long... but that's no problem. If you have a pressure-cooker it really speeds up the bit where you cook the clementines (or tangerines, or whatever).


  • 4-5 clementines (350--375g)
  • 6 eggs
  • 225 g sugar
  • 225 g ground almonds
  • 25 g flaked almonds
  • 3 or 4 cloves
  • 1 heaped tsp baking powder

Put the clementines (WHOLE AND UNPEELED, but without any stalky bits) into the pressure cooker, or a big pan with a lid. Add cold water to cover. If it's a pressure cooker, put the lid on, bring it up to pressure, and cook for 15-20 mins. If it's a normal pan, simmer gently (covered) for 2 hours.

Then turn off the heat, release the pressure, and let the clems and the water cool down. You have to let them cool before the next step, so the clementines don't scramble the eggs! Here's a picture of our clems cooling on the back step.

Put the clems into a food processor and blend them up. (It's handy to keep some of their cooking water in case the mixture needs a bit more liquid, but in my experience it's generally not needed.)

Crush the cloves in a pestle and mortar. Add the flaked almonds and crush them too. No need to crush the almonds too fine - the point of the flaked almonds is to give an occasional bit of crunch to the cake.

In a mixing bowl, whisk the eggs, then mix in the clementines. Then add everything else, and mix it up.

Pour into a 21cm springform tin (greased, and with baking paper in the bottom) and bake at 180 degrees (gas mark 4 or 5) for about an hour. Cover the cake loosely with greaseproof paper or a tray, for the last 20 minutes or so.

Take out of the oven and let it sit in the tin for 10--20 minutes or so, before turning it out onto a wire rack to cool properly.

Syndicated 2013-03-29 16:18:11 (Updated 2013-04-03 09:07:24) from Dan Stowell

Bird sound analysis with MPTK: chirp vs gabor

I'm just back from a great two-week research visit to INRIA in Rennes. The fruit of our labour will be a new release of the Matching Pursuit ToolKit with some whizzy extra features and polish. In my previous blog entry I showed how we can use Matching Pursuit to detect patterns in spectrograms - now I want to show you a quick example of how these techniques can give you a clearer, more meaningful representation of sounds such as birdsong.

On my way home one day I got a nice recording of a chiff-chaff, so we'll use that as our example. (I also put the longer audio on Xeno Canto as XC125867.)