The Gaussian Process is an incredibly interesting object.
Paraphrasing from Rasmussen & Williams 2006, a Gaussian Process is a stochastic process (a collection of random variables, indexed on some set) where any finite number of them have a multivariate normal distribution.
Sample paths of GPs can represent functions. They also have many different interpretations, e.g. in the sense of covariances or basis function representations.
An MVN is completely characterized by its mean and covariance, and in the case of a GP, we can use the covariance to specify what sort of a function space we want to look at. For example, to create a representation of a continuous function, let be a vector of points corresponding to domain points . To enforce continuity, all we need is:
Covariance between points is usually enforced using kernels, so for example, this is the RBF kernel:
This can be scaled (hence scaling the function along the y-axis), and a scale (the length-scale) can be applied to the domain variables. The function enforced by this kernel is infinitely differentiable, because the kernel itself is infinitely differentiable.
Knowing a few (“training”) points, one can predict all points between the training points (i.e. smoothing) by using the fact that, if is the set of training points, the conditional distribution of the predicted points is also multivariate normal:
In this case, , but interestingly, due to the linearity of the MVN, a derivative of a GP is also a GP assuming that the mean and covariance are differentiable, in which case, the kernels are:
Prior Draw from a Gaussian Process
GP Prior Draw Code
Posterior of a Gaussian Process
We fit a GP with an RBF kernel and lengthscale 1.0 to the points: .
GP Posterior Code
Derivatives of the GP
I’ve written a piece to calculate the derivative kernels efficiently, but I’m still testing this:
GP Derivative Covariances (1-D)
This seems to work and I’ve used (previous versions of it, coupled with Tensorflow’s Adam and Stan’s HMC/l_BFGS) to solve differential equations:
Modeling SDE equivalents of GPs
There’s some great literature out there about modeling GPs as solutions of differential equations with a random component, but before I encountered that, the following was a brute-force attempt to model the functions where is a continuous time stochastic process and is the standard Weiner process:
When is a Gaussian Process, equating the Euler-Maruyama representation of the SDE above with the GP expressed as where is the Cholesky-decomposition of the covariance matrix, results in the random normal vector being exactly equal to the random part of the SDE: .
Hence modeling the functions and minimizing the distance between is a way to obtain those functions without solving the SDE. When this is mathematically infeasible, the algorithm fails.
Simo Särkkä has shown that GPs can be written as state space models, which are models of the form:
For the centered Matern GP:
Python code for Matern SSM-GP Simulation
I’ve got the suspicion that the RBF GP can’t be represented this way (easily) because it’s infinitely differentiable; the Matern GP isn’t, so a derivative of a high enough order would appear to be random (which is set to and integrating that many times over would lead to a nice function. So, it’s probably unsurprising that the RBF needs to be written as its infinite series representation and then represented as a SSM.
There’s also interesting literature out there about gaussian convolutional models, which in some sense, represent moving-average counterparts of the autoregressive approach above.
I used to do a fair bit of astrophotography in university - it’s harder to find good skies now living in the city. Here are some of my old pictures. I’ve kept making rookie mistakes (too much ISO, not much exposure time, using a slow lens, bad stacking, …), for that I apologize!
I’ve been reading about PPCA, and this post summarizes my understanding of it. I took a lot of this from Pattern Recognition and Machine Learning by Bishop.
The main objective of this post was just to write about my typical workflow and views rather than come up with a great model. The structure of this data is also outside my immediate domain so I thought it’d be fun to write up a small diary on making a model with it.
The main aim here was to morph space inside a square but such that the transformation preserves some kind of ordering of the points. I wanted to use it to generate some random graphs on a flat surface and introduce spatial deformation to make the graphs more interesting.
I had a go at a few SEIR models, this is a rough diary of the process.
The initial aim here was to model speech samples as realizations of a Gaussian process with some appropriate covariance function, by conditioning on the spectrogram. I fit a spectral mixture kernel to segments of audio data and concatenated the segments to obtain the full waveform. Partway into writing efficient sampling code (generating waveforms using the Gaussian process state space representation), I realized that it’s actually quite easy to obtain waveforms if you’ve already got a spectrogram.
I’ll try to give examples of efficient gaussian process computation here, like the vec trick (Kronecker product trick), efficient toeliptz and circulant matrix computations, RTS smoothing and Kalman filtering using state space representations, and so on.
Minimal Working Examples
First of my experiments on audio modeling using Gaussian processes. Here, I construct a GP that, when sampled, plays middle c the way a grand piano would.
… using Stan & HMC