dfm / george

Fast and flexible Gaussian Process regression in Python
http://george.readthedocs.io
MIT License
450 stars 128 forks source link

Negative constant kernel #125

Open arodland opened 4 years ago

arodland commented 4 years ago

Considering that george supports the CosineKernel it probably can cope with negative covariances. My model instead uses an ExpSine2Kernel offset by a negative constant. But since ConstantKernel is parameterized by the log of the constant, it's impossible to specify a negative constant. I tried using -1 * ConstantKernel(abs_value) but that doesn't work either, probably since the * overload just constructs a ConstantKernel anyway.

arodland commented 4 years ago

https://github.com/arodland/george/commit/dae729323d1b7cea5eef661a8ee3bb7a6d5b442e seems to work fine although I'm not sure if it's the best approach.

stefanocovino commented 4 years ago

Did you have any specific comment? I have exactly the same problem... :) essentially how to model processes with a (partially, at least) negative ACF.

Stefano

arodland commented 4 years ago

@stefanocovino my branch is working 100% fine for me. Just hoping for an opinion from @dfm .

stefanocovino commented 4 years ago

My first, naive, feeling is only that mathematically it could work, however by itself a negative kernel is probably not a kernel, at least according to Eq. 4.2 in Rasmussen and Williams. O course if you are just summing it to some other kernel what counts is the total sum that might well satisfy Eq. 4.2, possibly limiting the value of the constant. My 2 cents.

Bye, Stefano

arodland commented 4 years ago

@stefanocovino yes, you're absolutely right, a negative constant is certainly not a kernel by that definition, but I don't care too much for terminological purity, and positive-semi-definiteness does get enforced on the final result when the solver tries to compute with it.