(A Creative Blog Name Here)

Code, math, and other things I find useful

Fixing IPython plot windows after OS X upgrade

Note: These instructions are for the Conda Python environment manager. They should be adaptable to Virtualenv installations or others as well.

Often after installing OS X upgrades plots created in IPython open behind all windows and cannot be tabbed to. The following instructions should fix this:

  1. Remove the current python ...

Variational lower-bound for hidden Markov models

if you define the forward messages as the filtering distribution (like Beal), then the normalization constant from the update is \(p(y_t | y_{1:t-1})\).

If you define the forward messages as the joint \(p(y_{1:t}, x_t)\) like Emily does (and like Matt and we do), then the ...

Convergent Series and lim inf

This little result came up when proving the convergence of a stochastic gradient algorithm and I want to write it down to remember it after discussions with Matt Johnson and Alex Tank.

Let \(a_1, a_2, \ldots\) be a positive sequence of numbers. If \(\sum_{n=1}^\infty \frac{1}{n ...

Debugging Python Extensions With Valgrind

In order to get line numbers when using Valgrind to debug Python extensions written in c/c++ you need to compile the extension with both the -O0 and the -g flags.

Eigen Weirdness #1: Broadcasting

I have needed to implement some of my research code in C++ and I have been using the Eigen library for linear algebra. There are a lot of great things about Eigen, however, there are some hang-ups I have run into that do not seem to be documented anywhere. As ...

Migrating the Blog to Github Pages

The account at my former institution was recently deleted. Unfortunately, I was hosting this blog there and so I was forced to migrate it somewhere else. I have always wanted to host the blog on Github Pages (where my site is hosted) and this seemed like good enough excuse to ...

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 ...

Types as function arguments in Julia

The multiple dispatch mechanism in Julia makes passing types as arguments to functions desirable. This technique is sometimes referred to as "types as tags" and a contrived example is presented below.

type A
end

type B
end

f(::Type{A}) = println("f with type A")
f(::Type{B}) = println("f ...

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 ...

Matplotlib 3D plots in IPython

Summary:

Assume that

import matplotlib.pyplot as plt

has been executed.

When using mplot3d in IPython you have to manually draw the axes which can be done using the plt.draw function (or plt.plot([],[])).
For some reason the axes are not automatically drawn as with 2d plots.

The full ...