pymc_forecast.gaussian#
Correlated-over-time observation noise: the Gaussian prefix conditional.
For elementwise noise the forecast distribution is the horizon marginal (what
predict() does implicitly). When the observation
noise is a MultivariateNormal over the time axis — GP-style correlated
residuals — the forecast must instead be the Gaussian conditional given the
observed prefix. This module ports numpyro_forecast’s _mvn_prefix_condition
(Cholesky of the prefix block, triangular solves for the conditional mean and
covariance, jitter + symmetrization) to PyTensor and wires it into a
predict-style primitive.
Univariate series only (the MVN event dimension is time), matching upstream.
- pymc_forecast.gaussian.conditional_mvn(loc, cov, observed_prefix, *, jitter=1e-06)[source]#
Condition a length-
t+fMVN on its firsttobserved values.- Parameters:
loc (
numpy.ndarrayorpytensor.tensor.TensorVariable) – Full-horizon mean, shape(t + f,); must be a tensor whenobserved_prefixis a tensor.cov (
numpy.ndarrayorpytensor.tensor.TensorVariable) – Full-horizon covariance, shape(t + f, t + f); it is symmetrized before use.observed_prefix (
numpy.ndarrayorpytensor.tensor.TensorVariable) – Observed values, shape(t,).jitter (
float, default1e-6) – Additive diagonal term, added to the symmetrized joint covariance and again to the conditional covariance.
- Returns:
cond_mean (
pytensor.tensor.TensorVariable) – Mean of the forecast conditional, shape(f,).cond_cov (
pytensor.tensor.TensorVariable) – Covariance of the forecast conditional, shape(f, f).
- pymc_forecast.gaussian.predict_mvn(h, loc, cov, *, jitter=1e-06)[source]#
Register MVN-over-time observation/forecast variables.
The correlated-noise counterpart of
predict(): the likelihood isMvNormalover the observed window (the prefix block ofcov) and — when forecasting — the"forecast"variable is the exact Gaussian conditional given the observed prefix, not the horizon marginal.Only
"obs"and (when forecasting)"forecast"are registered; unlikepredict(), no"mu"/"mu_future"Deterministics are recorded.- Parameters:
h (
pymc_forecast.model.Horizon) – The horizon of the current model build; its data, if any, must be 1-D.loc (
array_likeorpytensor.tensor.TensorVariable) – Full-horizon mean with shape(duration,)(time on axis 0).cov (
array_likeorpytensor.tensor.TensorVariable) – Full-horizon covariance with shape(duration, duration)— e.g. a GP kernel gram matrix over the time positions.jitter (
float, default1e-6) – Additive diagonal term for numerical stability, added to the symmetrized covariance and again to the conditional forecast covariance (seeconditional_mvn()).
- Raises:
pymc_forecast.exceptions.HorizonError – If the data are multivariate (the MVN event dim must be time), or if forecasting without observed data.