class_docstr: 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.
  
  Examples
  --------
  .. code:: python
  
      # 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(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)
  
  References
  ----------
  -   Ruitort-Mayol, G., and Anderson, M., and Solin, A., and Vehtari, A. (2022). Practical
      Hilbert Space Approximate Bayesian Gaussian Processes for Probabilistic Programming
class_docstr_tok: ["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",".","Examples","--","--","--","--","..","code",":",":","python","#","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","(","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",")","References","--","--","--","--","--","-","Ruitort-Mayol",",","G.",",","and","Anderson",",","M.",",","and","Solin",",","A.",",","and","Vehtari",",","A",".","(","2022",")",".","Practical","Hilbert","Space","Approximate","Bayesian","Gaussian","Processes","for","Probabilistic","Programming"]
code: def _build_conditional(self, Xnew):
      try:
          beta, X_mean = self._beta, self._X_mean
  
      except AttributeError:
          raise ValueError(
              "Prior is not set, can't create a conditional.  Call `.prior(name, X)` first."
          )
  
      Xnew, _ = self.cov_func._slice(Xnew)
  
      phi_cos, phi_sin = calc_basis_periodic(
          Xnew - X_mean, self.cov_func.period, self._m, tl=pt
      )
      m = self._m
      J = pt.arange(0, m, 1)
      # rescale basis coefficients by the sqrt variance term
      psd = self.scale * self.cov_func.power_spectral_density_approx(J)
  
      phi = phi_cos @ (psd * beta[:m]) + phi_sin[..., 1:] @ (
          psd[1:] * beta[m:]
      )
      return self.mean_func(Xnew) + phi
  
imports: import numbers
  import warnings
  from types import ModuleType
  from typing import Optional, Sequence, Union
  import numpy
  import pytensor.tensor
  import pymc
  from pymc.gp.cov import Covariance, Periodic
  from pymc.gp.gp import Base
  from pymc.gp.mean import Mean, Zero
label_desc: Use image node_id 4 for calling the HSGPPeriodic obj's underlying member method code with example usage: obj._build_conditional(Xnew) and returns: unknown