SheffieldML / GPy

Gaussian processes framework in python
BSD 3-Clause "New" or "Revised" License
2.02k stars 558 forks source link

Bugs & comments to GPy/GPy/kern/src/stationary.py #897

Closed hoo-ray closed 3 years ago

hoo-ray commented 3 years ago
  1. class ExpQuad(Stationary): The class docstring reports the wrong equation. The reported equation is that for Matern52: k(r) = \sigma^2 (1 + \sqrt{5} r + \\frac53 r^2) \exp(- \sqrt{5} r) The correct equation would be: k(r) = \sigma^2 \exp(-\\frac12 r^2)

  2. class RatQuad(Stationary): The kernel equation here is not consistent with the book "Gaussian Processes for Machine Learning, C. E. Rasmussen, C. K. I. Williams". In the book, the rational quadratic covariance function is given as equation (4.19). What is missing here is alpha (i.e. the power term) in the denominator inside the parentheses. current implementation (with error): docstring: k(r) = \sigma^2 \\bigg( 1 + \\frac{r^2}{2} \\bigg)^{- \\alpha}

    def K_of_r():
        r2 = np.square(r)
    #         return self.variance*np.power(1. + r2/2., -self.power)
        return self.variance*np.exp(-self.power*np.log1p(r2/2.))

    Note: the commented out equation matches the docstring, both are missing the alpha term in the denominator.

This is consistent with the book: docstring: k(r) = \sigma^2 \\bigg( 1 + \\frac{r^2}{2 \\alpha} \\bigg)^{- \\alpha}

def K_of_r():
        r2 = np.square(r)
#         return self.variance*np.power(1. + r2/(2.*self.power)., -self.power)
        return self.variance*np.exp(-self.power*np.log1p(r2/(2.*self.power)))
  1. class Exponential(Stationary): The class docstring is missing.
ekalosak commented 3 years ago

@lawrennd your PR fixed this, right?

lawrennd commented 3 years ago

Oh ... I believe so yes ... although if I recall the PR was triggered by adding a feature so the fix was a side-effect ... but I think this can be closed!