You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue relates to the docstring of the kernel_f method in mogp_emulator.Kernel.KernelBase. The docstring says the params argument should be "1-D with length one greater than the last dimension of x1 and x2". This does not appear to match the current implementation, which I think expects params to be a 1-dim Numpy array with length equal to the last dimensions of x1 and x2.
Aside from this, the documentation should make clear what these params refer to mathematically. Having looked at the implementation of SquaredExponential, I think these are meant to be the 'raw' version of the correlation length scale parameters (as outlined in the docstring for GPParams), although it would be good to get a package maintainer to confirm this. This would also seem to indicate that the kernels assume that the covariance is equal to 1 (again using the terminology of the docstring for GPParams). If true, this again needs to be made clear in the documentation, because it differs from other mathematical treatments of kernel functions (see e.g. https://uk.mathworks.com/help/stats/kernel-covariance-function-options.html).
We consider only SquaredExponential and Matern52 below, but similar problems arise for the other named kernels, ProductMat52, UniformSqExp and UniformMat52.
>>>importnumpyasnp>>>frommogp_emulator.KernelimportMatern52, SquaredExponential>>>x1=np.random.random(3)
>>>x2=np.random.random(3)
>>>params=np.array([1, 2, 3, 4]) # len = x1.shape[-1] + 1 = x2.shape[-1] + 1, as per documentation for kernel_f>>>Matern52().kernel_f(x1, x2, params)
>>>SquaredExponential().kernel_f(x1, x2, params)
Expected behaviour
The expressions Matern52().kernel_f(x1, x2, params) and SquaredExponential().kernel_f(x1, x2, params) evaluate to a single-element Numpy array of shape (1, 1).
Summary
This issue relates to the docstring of the
kernel_f
method inmogp_emulator.Kernel.KernelBase
. The docstring says theparams
argument should be "1-D with length one greater than the last dimension ofx1
andx2
". This does not appear to match the current implementation, which I think expectsparams
to be a 1-dim Numpy array with length equal to the last dimensions ofx1
andx2
.Aside from this, the documentation should make clear what these
params
refer to mathematically. Having looked at the implementation ofSquaredExponential
, I think these are meant to be the 'raw' version of the correlation length scale parameters (as outlined in the docstring forGPParams
), although it would be good to get a package maintainer to confirm this. This would also seem to indicate that the kernels assume that the covariance is equal to 1 (again using the terminology of the docstring forGPParams
). If true, this again needs to be made clear in the documentation, because it differs from other mathematical treatments of kernel functions (see e.g. https://uk.mathworks.com/help/stats/kernel-covariance-function-options.html).Versions used
Python 3.9.18
mogp-emulator 0.7.2
numpy 1.26.3
scipy 1.11.4
patsy 0.5.6
Reproducible example of error
We consider only
SquaredExponential
andMatern52
below, but similar problems arise for the other named kernels,ProductMat52
,UniformSqExp
andUniformMat52
.Expected behaviour
The expressions
Matern52().kernel_f(x1, x2, params)
andSquaredExponential().kernel_f(x1, x2, params)
evaluate to a single-element Numpy array of shape(1, 1)
.Actual behaviour
The text was updated successfully, but these errors were encountered: