Slice sampling Matlab demo

So far we’ve had a look at rejection sampling and importance sampling. Here we take a quick look at slice sampling, although rather than implementing it ourselves, we will use the built in Matlab slicesample function. Using our parameter estimation example, we will use slice sampling to estimate the mean and sigma of some samples from …

Importance sampling Matlab demo

Importance sampling is related to rejection sampling, which I looked at in the last post. Here is a short demo. %% true probability distribution true_func = @(x) betapdf(x,1+1,1+10); %% Do importance sampling N = 10^6; % uniform proposal distribution x_samples = rand(N,1); proposal = 1/N; % evaluate for each sample target = true_func(x_samples); % calculate importance …

Rejection sampling Matlab demo

I’ve been using MCMC, but I’ve wanted to flesh out my knowledge and explore the space of sampling approaches a little more. One very simple, yet inefficient method, is rejection sampling. Here is a little Matlab example I put together after seeing how easy it was. %% true probability distribution true_func = @(x) betapdf(x,1+1,1+10); %% Do …

Plotting posterior predictive distributions

I’ve just released a small bit of Matlab code on GitHub which helps automate the job of plotting posterior predictive distributions. If you are inferring posterior distributions of parameters of a 1D function (e.g. y=mx+c) then this code will plot the posterior predictive distribution for you. This should be handy for you to eyeball how well a model …

Energy efficient receptive field code

[UPDATE: February 2014] The files and instructions are now hosted on GitHub.   Energy efficient receptive field code by Benjamin Vincent is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 3.0 Unported License. This minimal set of MATLAB functions will set up a simple neural network to learn receptive fields. These receptive fields minimise an energy function which involves a) …