Haversine Kernel?

Hi @Galen_Seilis, that’s a great question with an uncomfortable answer. I had the same question some years ago, and I ended up implementing a Matern kernel that used the Haversine distance (actually the grand-circle distance), and I had to dig deep to find out why my kernel gave back such huge CRAP.

I think that you had the same intuition that I had, use the Haversine distance instead of the Euclidean distance with a standard kernel like one from the Matern family. The short answer is that you cannot simply put any distance function inside of a Matern kernel and hope that the result works as a valid kernel (insert Boromir meme). For a short discussion, you can read section 2.1 here. Defining kernels on manifolds, like a sphere is perfectly possible, but you have to be careful that you end up with a positive semidefinite function at the end (the only real property required by a GP covariance kernel). Putting the Haversine inside Matern, is not positive semidefinite, and makes your GP wrong (it’s like trying to model Gaussian noise using a negative variance).

There are a couple of easy ways around this problem:

  1. Use the Chordal distance instead of the grand-circle distance. This works because Chordal distance is simply Euclidean distance of points that are constrained to be on the surface of a sphere.
  2. Work with projections onto flat 2D planes. An example of this is the UTM system.

The harder path, is to try to actually find a way to get kernels that work with the grand-circle distance. You can have a look at the reference I shared earlier, or you could also try out the things these people say, keeping in mind that they actually want to be able to use non-stationary kernels on the sphere.

7 Likes