GP4C¶
High-performance C implementation with Python bindings for sampling from joint Gaussian Processes with integral and derivative relationships.
Overview¶
Sample from joint GP \((f, g, h, u)\) where:
- \(f(x) \sim \mathcal{GP}(0, k_f)\) — original process with RBF kernel
- \(g(x) = \int_0^x f(t) dt\) — integrated process
- \(h(x) = f'(x)\) — first derivative process
- \(u(x) = f''(x)\) — second derivative process
All are correlated through proper cross-covariance structures. Sample any subset on different grids, and condition on observations of any combination.
Key Features¶
- Fast C implementation using GSL
- Zero-copy Cython wrapper for NumPy integration
- Four-way joint sampling of function, integral, first derivative, and second derivative
- Posterior sampling conditioned on observed data
- Mixed observations — observe f, predict h or u, or any combination
- Mathematically rigorous covariance structure
- Fully tested with comprehensive unit tests
Quick Example¶
import numpy as np
import marimo as mo
import matplotlib.pyplot as plt
from gp4c import sample_prior, SamplingSpec
x = np.linspace(0, 5, 100)
spec = SamplingSpec(x_f=x, x_g=x)
result = sample_prior(spec, sigma2=1.0, ell=0.5, n_samples=5)
# Plot function samples
for i in range(5):
plt.plot(x, result.f[i], alpha=0.7, label=f'f_{i}')
plt.legend()
plt.show()
Next Steps¶
- Installation Guide - Install gp4c
- Quick Start - First steps with examples
- Tutorials - In-depth guides
- API Reference - Complete function documentation