Wednesday, January 31, 2007


I decided to post about this to help spread the word about this very cool, elegant an useful Python application. Its called KeyJnote.

In short, it is a presentation tool that displays your PDF presentation in a light, OpenGL accelerated, and full of eye candy way. Amazingly enough, it consists in a single Python script, and is available to all platforms Python supports, i.e., all imaginable. For lazy windows users that don't want to install the requirements, it is available as a single .exe file. I included a few screenshots to give you a flavor of it:

Sunday, January 14, 2007

Object Oriented Bayesian Inference

A couple of days ago, while working on a chapter of my book, I came across a manuscript from Kerman and Gelman, from Columbia University talking about a fully Bayesian computing environment. They argue that the basic building block for such a system, would be a "random variable" data type.

I liked their paper. Especially because I was already thinking along those lines for a while. So I decided to give it a shot. Well it was easy, since I already had a nice library for calculating likelihood functions, I didn't have to implement that. I came down to about a hundred lines of Python code (not counting the likelihood library)

I was pretty impressed with it, I had a object that I could specify from a prior distribution, that I could throw data at it and it would return a posterior distribution, a likelihood function, samples from the posterior, etc.

Pretty nice! It also allows the recursive inference typical of Bayesian statistics by which, if available, the posterior becomes the prior when new data is available.

It can still be extended by inhering from basic types such a numpy array. This would allow for this object to be used as a full-fledged type and participate in all sorts of mathematical operations...

Since the code is a bit long and blogger sucks at posting code, I am simply adding a UML representation of the class. If you are interested in discussing about this, getting access to the code or make suggestions, please email me or just leave a comment.

Monday, January 8, 2007

Finding your social network from your Mailbox

I work with networks as part of my research, so I never let a good idea about exploring complex networks pass.

One problem with working with complex networks, is that it is very hard to define them. We interact with complex systems all the time, often composed of hundreds if not thousands of elements connected together. But to capture them in a quantitative representation, thats the big challenge!

A few months ago, I came up with this simple way to build a fully parameterized social network, from a Mailbox, with a simple Python script.

In this post I present a simple version it, for illustrative reasons, but one that is very easy to extend to capture other aspects of the real Social Network. Here it goes:

Friday, January 5, 2007

Building Pyrex with SCons

I have to admit that I like SCons. Maybe it is because I hate Make. Not really, SCons is really a great build tool. A few days ago, when I was working on the Pyrex section of the extensions chapter of my book, I got an itch to automate the building of Pyrex extension modules with SCons. As I decided to scratch that itch, I was surprised by the total lack of documentation on how to build Pyrex modules with SCons!

So I would have to do it the hard way. Fortunately, SCons makes it very easy to develop custom Builders. So after a couple of hours I had a working Pyrex Builder.

It could have been done quicker, If the LIBPATH keyword in the SharedLibrary function worked the way I expected. One other Annoyance was the fact that SCons prepends 'lib' to the name of a shared library, not respecting your wishes. This turned out to be a real problem: I painfully found out that if the name of the .so is not the same as the original .pyx source, You get an importError. I fixed that by manually renaming the .so file. If anyone knows of a better solution to this problem, please post a comment.

I also did not test this for building multiple files and other variations. If anyone feels like trying, please let me know how it goes.

here is the SConstruct code: