Tag: statistics

Interpolated list class for Python

Posted by – 2009/12/12

While messing with Python to output some better graphs for my Facebook group scraper I stumbled upon an interesting problem. What happens if you have missing samples, or want to change the sampling frequency half way through your log? Well, you could use a proper math library and have extra dependencies or generate the missing data manually, but the simplest answer I could think of was to write a list class which interpolates between missing values, so you can do something like this:

>>> a = InterpoList()
>>> a[0]   = 0
>>> a[100] = 200
>>> a[200] = 0
>>> a[50]
100.0
>>> a[125]
150.0

And then store the time values as seconds past the epoch. Now I can inject data from multiple sources taken at different frequencies and retrieve an interpolated value for any time, which means more nice graphs like this:

As usual I also decided to share it with the Internet, because I’m nice like that! You can get a copy of the InterpoList module here.

Piwik in, Google Analytics out

Posted by – 2009/08/27

I’ve stopped using Google Analytics and have now moved over to Piwik. I don’t have that many visitors, but there are still lots of good reasons to use Piwik. It’s better for everyone if I keep hold of my own stats instead of giving it all to Google and I may even do some Piwik hacking in the future.

Getting it working in Gallery2 was a bit of a pain, so I updated their wiki for them, but other than that it’s about the same as installing Google Analytics.

Subscribers are welcome to see my laughable stats :)