### Off-the-shelf optimization functions in Matlab

Estimating a statistical model via maximum likelihood or MAP involves minimizing an error function – the negative log-likelihood or log-posterior. Generic functions built in to Matlab like fminunc and fmincon will often do the trick. There are many other free solvers available, which are often faster, or more powerful: Solvers by Mark Schmidt: there’s a huge collection of functions from Mark … More Off-the-shelf optimization functions in Matlab

### Fast 1D and 2D data binning in Matlab

I needed a fast method of binning 1D and 2D data in Matlab – that is, to compute the mean of z conditional on x being in a given range (1d binning) or the mean z of conditional on x and y being in given ranges (2d binning). I stumbled upon this very clever method … More Fast 1D and 2D data binning in Matlab

### Load pickle files in Matlab

It’s easy enough to load .mat files in Python via the scipy.io.loadmat function. But what about loading .pickle files into Matlab? That’s easy enough by calling a system command in Matlab, like so: Note that I’m setting the LD_LIBRARY_PATH environment variable since Matlab seems to reset this variable internally and it causes .so module import … More Load pickle files in Matlab

### Whiten images in Matlab

Previously, I showed how to whiten a matrix in Matlab. This involves finding the inverse square root of the covariance matrix of a set of observations, which is prohibitively expensive when the observations are high-dimensional – for instance, high-resolution natural images. Thankfully, it’s possible to whiten a set of natural images approximately by multiplying the … More Whiten images in Matlab

### Deinterlace a movie in Matlab

Here’s a simple function to deinterlace a movie that was interlaced to go from 24fps to 30fps: