# pymc.gp.HSGPPeriodic#

class pymc.gp.HSGPPeriodic(m, scale=1.0, *, mean_func=<pymc.gp.mean.Zero object>, cov_func)[source]#

Hilbert Space Gaussian process approximation for the Periodic covariance function.

Note, this is not actually a Hilbert space approximation, but it comes from the same paper (Ruitort-Mayol et al., 2022. See Appendix B) and follows the same spirit: using a basis approximation to a Gaussian process. In this case, the approximation is based on a series of stochastic resonators.

For these reasons, we have followed the same API as gp.HSGP, and can be used as a drop-in replacement for gp.Latent. Like gp.Latent, it has prior and conditional methods.

For information on choosing appropriate m, refer to Ruitort-Mayol et al.. Note, this approximation is only implemented for the 1-D case.

To work with the approximation in its “linearized” form, as a matrix of basis vectors and a vector of coefficients, see the method prior_linearized.

Parameters:
m: int

The number of basis vectors to use. Must be a positive integer.

scale: TensorLike

The standard deviation (square root of the variance) of the GP effect. Defaults to 1.0.

cov_func: Must be an instance of instance of `Periodic` covariance
mean_func: None, instance of Mean

The mean function. Defaults to zero.

References

• Ruitort-Mayol, G., and Anderson, M., and Solin, A., and Vehtari, A. (2022). Practical Hilbert Space Approximate Bayesian Gaussian Processes for Probabilistic Programming

Examples

```# A three dimensional column vector of inputs.
X = np.random.rand(100, 3)

with pm.Model() as model:
# Specify the covariance function, only for the 1-D case
scale = pm.HalfNormal("scale", 10)
cov_func = pm.gp.cov.Periodic(1, period=1, ls=0.1)

# Specify the approximation with 25 basis vectors
gp = pm.gp.HSGPPeriodic(m=25, scale=scale, cov_func=cov_func)

# Place a GP prior over the function f.
f = gp.prior("f", X=X)

...

# After fitting or sampling, specify the distribution
# at new points with .conditional
Xnew = np.linspace(-1, 2, 50)[:, None]

with model:
fcond = gp.conditional("fcond", Xnew=Xnew)
```

Methods

 `HSGPPeriodic.__init__`(m[, scale, mean_func]) `HSGPPeriodic.conditional`(name, Xnew[, dims]) Returns the (approximate) conditional distribution evaluated over new input locations Xnew. `HSGPPeriodic.marginal_likelihood`(name, X, ...) `HSGPPeriodic.predict`(Xnew[, point, given, ...]) `HSGPPeriodic.prior`(name, X[, dims]) Returns the (approximate) GP prior distribution evaluated over the input locations X. Linearized version of the approximation.