GPWithMCMC<T>
Models & Types · AiDotNet.GaussianProcesses
Gaussian Process with Markov Chain Monte Carlo inference for full Bayesian treatment.
Inheritance: ModelBase<T, Matrix<T>, Vector<T>> → GaussianProcessBase<T> → GPWithMCMC<T>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
Standard GP makes point estimates of hyperparameters (kernel lengthscale, output variance, noise variance). MCMC provides a fully Bayesian treatment by sampling from the posterior distribution of hyperparameters, giving better uncertainty quantification.
Instead of finding a single “best” lengthscale, MCMC explores many plausible lengthscales and averages predictions across all of them. This is more robust when:
- You have limited data
- The hyperparameters are uncertain
- You need accurate uncertainty estimates
The implementation uses Slice Sampling, which automatically adapts to the target distribution without requiring careful tuning of step sizes.
Constructors
| Constructor | Summary |
|---|---|
GPWithMCMC(IKernelFunction<T> kernel, int numSamples, int burnIn, int thinning, double logLengthscalePriorMean, double logLengthscalePriorStd, double logVariancePriorMean, double logVariancePriorStd, int? seed) |
Initializes a GP with MCMC inference. |
Properties
| Property | Summary |
|---|---|
IKernelFunction<T> Kernel { get; } |
Gets the kernel function. |
bool IsTrained { get; } |
Gets whether the GP is trained. |
int NumStoredSamples { get; } |
Gets the number of stored MCMC samples. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, ValueTuple<double, double>> GetPosteriorStatistics() |
Computes posterior statistics for hyperparameters. |
List<double[]> GetSamples() |
Gets the MCMC samples [lengthscale, outputVariance, noiseVariance]. |
ValueTuple<T, T> Predict(Vector<T> x) |
Predicts at a single test point with full posterior averaging. |
ValueTuple<Vector<T>, Vector<T>> PredictBatch(Matrix<T> Xtest) |
Predicts at multiple test points. |
void Fit(Matrix<T> X, Vector<T> y) |
Fits the GP to training data using MCMC sampling. |
void UpdateKernel(IKernelFunction<T> newKernel) |
Updates the kernel (not supported for MCMC GP). |