(A Creative Blog Name Here)

Code, math, and other things I find useful

Calling Rmath from cython (sometimes R just does it better)

Recently I was writing some code that required the quantile function of the chi-squared distribution. There is a function in ccipy that implements this function, however, calling a python function from cython is slow. The scipy implementation calls a function in the cephes library. Unfortunately, scipy compiles the cephes library ...

Cleaning Cython Build Files

Whenever I use a setup.py script to build Cython code a variety of files are created including a .so file, one or more .c files and perhaps others. Until today I would delete these by hand as I did not have the patience to delve into what a setup ...

Cython and GSL made easy

I just found CythonGSL on Github that wraps the GSL library for use with Cython. Installation is simple

$ git clone git://github.com/twiecki/CythonGSL.git 
$ cd CythonGSL
$ python setup.py build
$ python setup.py install

I have also added this to my behemoth instructions on setting up python.

Cythonizing instance methods

A large amount of my work involves writing MCMC samplers. The models I work with have a lot of parameters and the samplers require a lot of state to be recorded. Normally, I stuff all of the parameters and state into a Python class and implement the different steps of ...