class gpr::ConditionalPosterior

Overview

Conditions a frozen GP posterior on disjoint new observation channels. More…

#include <gpr/ml/ConditionalPosterior.h>
 
class ConditionalPosterior {
public:
    // construction
 
    ConditionalPosterior(Eigen::MatrixXd background_covariance, Eigen::VectorXd residual, Eigen::VectorXd noise_variance, std::shared_ptr<linalg::DistributedState> execution = {});
 
    // methods
 
    bool condition(const Eigen::MatrixXd& active_covariance);
    Eigen::Index channels() const;
    bool conditionForLikelihood(const Eigen::MatrixXd& active_covariance);
    void prepareLocalPrediction();
    bool hasLocalPredictionFactor() const;
    Eigen::Index localPredictionFactorStoredElementsForTesting() const;
    const Eigen::VectorXd& residual() const;
    const Eigen::MatrixXd& backgroundCovariance() const;
    bool valid() const;
    const Eigen::VectorXd& weights() const;
    double negativeLogLikelihood() const;
    double negativeLogLikelihoodDerivative(const Eigen::MatrixXd& covariance_derivative) const;
    Eigen::MatrixXd negativeLogLikelihoodWeight() const;
    Eigen::VectorXd negativeLogLikelihoodDerivatives(const std::vector<Eigen::MatrixXd>& derivatives) const;
    double negativeLogLeaveOneGeometryOut(Eigen::Index geometry_rows) const;
    Eigen::VectorXd predictMean(const Eigen::VectorXd& background_mean, const Eigen::MatrixXd& cross_covariance) const;
    Eigen::MatrixXd predictCovariance(const Eigen::MatrixXd& query_prior, const Eigen::MatrixXd& cross_covariance) const;
    double schurRelativeError() const;
    Eigen::VectorXd predictVariance(const Eigen::VectorXd& query_prior, const Eigen::MatrixXd& cross_covariance) const;
    Eigen::MatrixXd whitenPredictionCrossCovariance(const Eigen::MatrixXd& cross_covariance) const;
};

Detailed Documentation

Conditions a frozen GP posterior on disjoint new observation channels.

The background covariance and residual y - m_background are fixed during an active-kernel fit. Only the new-channel covariance is factorized. Means, covariances and noise must use the same physical output units.

Methods

bool condition(const Eigen::MatrixXd& active_covariance)

Fit an additive active kernel; a zero matrix gives exact sequential conditioning under the background kernel alone. False marks an invalid posterior and requires a feasible covariance before prediction.

bool conditionForLikelihood(const Eigen::MatrixXd& active_covariance)

Collective likelihood evaluation and derivatives without replicating the factor. Call prepareLocalPrediction before local covariance or LOO.

void prepareLocalPrediction()

Collective transfer of the fitted factor for rank-local predictions.

const Eigen::MatrixXd& backgroundCovariance() const

Latent background covariance before adding the correction and noise.

const Eigen::VectorXd& weights() const

Fitted coefficients in physical observation-channel order.

double negativeLogLikelihoodDerivative(const Eigen::MatrixXd& covariance_derivative) const

d(-log p(y_new | D_background))/d theta for one active parameter. The caller forms only the derivatives selected for optimization.

Eigen::MatrixXd negativeLogLikelihoodWeight() const

One lexical precision contraction serves every selected parameter. With a process group, conditioning and this contraction are collective; prediction and geometry LOO consume the replicated lower factor locally.

Eigen::VectorXd negativeLogLikelihoodDerivatives(const std::vector<Eigen::MatrixXd>& derivatives) const

Parameter contractions share one precision weight at the fitted point.

double negativeLogLeaveOneGeometryOut(Eigen::Index geometry_rows) const

Sum of whole-geometry LOO negative log predictive densities at fixed hyperparameters. Channel-major ordering groups indices r + c*n_rows.

Eigen::VectorXd predictMean(const Eigen::VectorXd& background_mean, const Eigen::MatrixXd& cross_covariance) const

Cross covariance is C_background(X,B) + K_active(X,B).

Eigen::MatrixXd predictCovariance(const Eigen::MatrixXd& query_prior, const Eigen::MatrixXd& cross_covariance) const

Query prior is C_background(X,X) + K_active(X,X). Observation noise is added by the caller only when a predictive, rather than latent, covariance is requested.

double schurRelativeError() const

Relative forward error of a Schur complement formed from this posterior’s lower factor (linalg::choleskySchurRelativeError). Needs the replicated factor; the dense copy is made on the call.

Eigen::VectorXd predictVariance(const Eigen::VectorXd& query_prior, const Eigen::MatrixXd& cross_covariance) const

Diagonal of the same conditional covariance without a query Gram matrix.

Eigen::MatrixXd whitenPredictionCrossCovariance(const Eigen::MatrixXd& cross_covariance) const

Columns are L^-1 C(B,X), so their inner products give the covariance reduction at selected query channels without an all-pairs Gram matrix.