george icon indicating copy to clipboard operation
george copied to clipboard

Examples for higher dimensional data

Open arkottke opened this issue 6 years ago • 2 comments

I am struggling with how to work with higher dimensional kernals. A little more information in the documentation or a tutorial would be very help. In my particular case, I am working with earthquake observations which include two positions (latitude and longitude of the epicenter, and latitude and longitude of the recording station).

Thanks.

p.s. George is pretty handy.

arkottke avatar Nov 29 '17 21:11 arkottke

This is probably late but here is a minimal example for multidimensional data

"""Minimal example showing multidimensional GP regression.
"""
import george
import numpy as np

x = np.linspace(0, 5*np.pi)
x = np.vstack((x,x)).T #2D data
#x.shape is now (50,2)

y = np.sin(x[:,0]) + np.cos(x[:,1])

kernel = george.kernels.ExpSquaredKernel(1, ndim=2)

gp = george.GP(kernel)
gp.compute(x)

#Note that multidimensional input requires a 2D array of data
#even for a single test point
x_test = np.array([[6, 6]])

print(gp.predict(y, x_test))
#Prints the mean and variance at the point `x_test`

The thing that people sometimes stumble over is the dimensionality of the x points that the GP is making a prediction at - the input must be a list of N-length arrays where each data point x is N dimensional.

tmcclintock avatar Nov 21 '19 18:11 tmcclintock

This is being addressed in #112 .

tmcclintock avatar Nov 21 '19 18:11 tmcclintock