grf_gp.inference module¶
- grf_gp.inference.pathwise_conditioning(x_train, x_test, phi, y_train, noise_std, batch_size, device)¶
Perform pathwise conditioning to sample from the Gaussian Process posterior.
This function implements the Matheron’s rule (or pathwise update) to produce exact posterior samples by perturbing prior samples with a correction term derived from the residuals of the observations.
The update follows the identity:
\[\mathbf{g}_{|\mathbf{y}}(\cdot) = \mathbf{g}(\cdot) + \hat{\mathbf{K}}_{(\cdot)\mathbf{x}} \left( \hat{\mathbf{K}}_{\mathbf{x}\mathbf{x}} + \sigma_n^2 \mathbf{I} \right)^{-1} \left( \mathbf{y} - (\mathbf{g}(\mathbf{x}) + \boldsymbol{\varepsilon}) \right)\]- Parameters:
x_train – Training node indices.
x_test – Test node indices.
phi – Feature matrix whose rows correspond to graph nodes.
y_train – Training targets.
noise_std – Observation noise standard deviation.
batch_size – Number of posterior samples to draw.
device – Device on which the computation is performed.
- Returns:
Posterior function samples at
x_testwith shape(batch_size, len(x_test)).
- grf_gp.inference.woodbury_pathwise_conditioning(x_train, x_test, phi, y_train, noise_std, batch_size, device)¶
Perform pathwise conditioning using a Woodbury solve in feature space.
This is the low-rank analogue of
pathwise_conditioningfor kernels of the form \(\hat{\mathbf{K}} = \mathbf{\Phi}\mathbf{\Phi}^\top\), where \(\mathbf{\Phi}\) has a small feature dimension. It applies the Woodbury identity to solve an equivalent system in small feature space.The update follows the identity:
\[\left( \mathbf{\Phi}_{\mathbf{x}}\mathbf{\Phi}_{\mathbf{x}}^\top + \sigma_n^2 \mathbf{I} \right)^{-1} = \sigma_n^{-2}\mathbf{I} - \sigma_n^{-4}\mathbf{\Phi}_{\mathbf{x}} \left( \mathbf{I} + \sigma_n^{-2} \mathbf{\Phi}_{\mathbf{x}}^\top \mathbf{\Phi}_{\mathbf{x}} \right)^{-1} \mathbf{\Phi}_{\mathbf{x}}^\top\]- Parameters:
x_train – Training node indices.
x_test – Test node indices.
phi – Low-rank feature matrix whose rows correspond to graph nodes.
y_train – Training targets.
noise_std – Observation noise standard deviation.
batch_size – Number of posterior samples to draw.
device – Device on which the computation is performed.
- Returns:
Posterior function samples at
x_testwith shape(batch_size, len(x_test)).