This is the first implementation of the periodic kernel proposed in issue #5:
Testing it with a few periodic test functions utilizing the mcmc sampler, the kernel fits them often perfectly after having observed a few (~15 in 1D) datapoints.
But often the predicted function can vary wildly in the beginning.
I would guess that this behaviour results from the low amount of samples the mcmc sampler collects.
I chose to provide the following parameters:
The periodicity p (ISO: params(1), ARD: params(0) to params(n_inputs - 1)) and
The length scale l (ISO: params(0), ARD: params(n_inputs) to params(2 * n_inputs - 1))
Let me know if you find something which could be improved.
Looking at the literature, the most common way of periodic kernel is equation (4.31) of Rassmusen and Williams http://www.gaussianprocess.org/gpml/chapters/RW.pdf
That's a totally different kernel. This one is stationary (although your implementation miss the norm part) and RW is non-stationary.
Just a couple of details of implementation:
- The order of parameters should be consistent. For 1D, ARD and ISO should be equivalent. For consistency with other kernels, the scale should go always first.
- The parameter should be l, not l^2.
- This is a header file. Put the constant pi in a local scope (e.g.: inside the operator) and never outside the namespace.
- I haven't found a periodic kernel with ARD in any paper, but having a different "p" and "l" per dimension can be problematic. RW version is trivial to implement as ARD because it's a just modified SE kernel.