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)$ — derivative process
- $u(x) = f''(x)$ — second derivative process
All are correlated through proper cross-covariance structures.
Key Features
- Fast C implementation using GSL (GNU Scientific Library)
- Zero-copy Cython wrapper for seamless NumPy integration
- Four-way joint sampling of function, integral, derivative, and second derivative
- Posterior sampling conditioned on observed data
- Mixed observations — observe f, predict h or u, or any combination
- Multiple kernels — RBF, Matérn 5/2, Matérn 3/2, periodic, locally-periodic
- Hyperparameter optimization via
fit()— maximize log marginal likelihood - Mathematically rigorous covariance structure
- Fully tested with comprehensive unit tests
Quick Install
Prerequisites
Install GSL first:
# macOS
brew install gsl
# Ubuntu/Debian
sudo apt-get install libgsl-dev
# Fedora/RHEL
sudo dnf install gsl-devel
Install Package
pip install -e .
Quick Start
import numpy as np
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,
seed=42
)
# result.f contains f samples, result.g contains integral samples
Documentation
Full documentation is available at: https://rcalderonb6.github.io/gp4c
Or build locally:
pip install mkdocs-material
mkdocs serve
Quick Links
Examples
Basic usage:
# Sample f and its derivative h
from gp4c import sample_prior, SamplingSpec
spec = SamplingSpec(x_f=x, x_h=x)
result = sample_prior(spec, sigma2=1.0, ell=0.5, n_samples=5)
Second derivative sampling:
# Sample f and its second derivative u = f''
from gp4c import sample_prior, SamplingSpec
spec = SamplingSpec(x_f=x, x_u=x)
result = sample_prior(spec, sigma2=1.0, ell=0.5, n_samples=5)
# result.f contains f samples, result.u contains f'' samples
Posterior sampling:
# Condition on observations
from gp4c import sample_posterior, Observations, SamplingSpec
x_train = np.array([0.0, 1.0, 2.0, 3.0, 4.0])
y_train = np.sin(x_train)
obs = Observations(x_f=x_train, y_f=y_train, noise_f=0.01)
x_test = np.linspace(0, 5, 100)
spec = SamplingSpec(x_f=x_test)
result = sample_posterior(obs, spec, ell=1.0, n_samples=10)
Hyperparameter optimization:
# Automatically find the best kernel parameters
import gp4c
import numpy as np
x = np.linspace(0, 10, 50)
y = np.sin(x) + np.random.default_rng(0).normal(0, 0.1, len(x))
obs = gp4c.Observations(x_f=x, y_f=y, noise_f=0.01)
result = gp4c.fit(obs, kernel='rbf')
print(f"sigma2={result.sigma2:.3f}, ell={result.ell:.3f}")
# Use result.sigma2 and result.ell directly in sample_posterior
See the examples/ directory and documentation for more.
Testing
pytest tests/ -v
C Library
The core can be used directly in C/C++ projects. See C Integration Guide.
Quick install as system library:
./install_library.sh # System-wide (requires sudo)
./install_library.sh --user # User install (no sudo)
Project Structure
gp4c/
├── gp4c/ # Python package
│ ├── gp4c.c # C implementation
│ ├── gp4c.h # C headers and constants
│ ├── _core.pyx # Cython wrapper
│ ├── types.py # Type definitions
│ ├── optimize.py # Hyperparameter optimization
│ └── cli.py # CLI commands (gp4c install, etc.)
├── docs/ # MkDocs documentation
├── tests/ # Test suite
├── examples/ # Example scripts
├── notebooks/ # Jupyter notebooks
└── mkdocs.yml # Documentation config
Contributing
Contributions welcome! See Contributing Guide.
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
License
MIT License - see LICENSE file for details.
Citation
If you use this package in your research, please cite:
@software{gp4c,
title = {gp4c: Fast Joint Gaussian Process Sampling with integral and derivative information},
author = {Calderón, Rodrigo},
year = {2026},
url = {https://github.com/rcalderonb6/gp4c}
}
References
- Solak et al. (2003) - Derivative observations in Gaussian process models
- Rasmussen & Williams (2006) - Gaussian Processes for Machine Learning
- GSL Manual - https://www.gnu.org/software/gsl/doc/html/
Metadata
Release files for gp4c 0.0.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gp4c-0.0.21.tar.gz | 220.9 kB | With provenance | Details for gp4c-0.0.21.tar.gz |
Built distributions (wheels)
Total release size: 19.1 MB
Release files / gp4c-0.0.21.tar.gz
| Download URL | gp4c-0.0.21.tar.gz |
|---|---|
| Size | 220.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bca4c44e62e10667d3f70de422c3c94e471ab72bb05c639459932e8a839262a5
|
|
BLAKE2b-256 checksum How to use checksums |
28c24a0ddbb69b7b8ed3195448cce4b8a5bc55cfc8eecbb53f206dc052a20280
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | gp4c-0.0.21-cp312-cp312-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
8cf846fad54ada1dd6d250dbdacc705aca204a0170b0bcd9ba29cc59811fdaf7
|
|
BLAKE2b-256 checksum How to use checksums |
5d818103586cc4c9be2c244164d337cd5a7503a429ab08e6c77578a54b97533e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp312-cp312-macosx_14_0_x86_64.whl
| Download URL | gp4c-0.0.21-cp312-cp312-macosx_14_0_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.12 macOS 14.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
7ad703510eb61e7205826a68b81079e0df32fecdc4a86031dcba348f78c636b8
|
|
BLAKE2b-256 checksum How to use checksums |
ec29e87db467891c17390da92a50bb2816cc536803e0769083b975c495241c6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp312-cp312-macosx_14_0_arm64.whl
| Download URL | gp4c-0.0.21-cp312-cp312-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.12 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7618823a7150bdf4544bfbae013e8df42736c85d22f52780f9085032fe75fa7a
|
|
BLAKE2b-256 checksum How to use checksums |
c9152c71cb1f53648d8e1a54a5cf82b6a2eff739a5c5b692961c6c4b86679917
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | gp4c-0.0.21-cp311-cp311-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
6c8755b84d386cf412893fbbc73bb37faecd7f963cdf033410dceae2d19a4d59
|
|
BLAKE2b-256 checksum How to use checksums |
a241c66950388963c7faff9348dce7472499c05ee88b1a488a3e60c75c810e5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp311-cp311-macosx_14_0_x86_64.whl
| Download URL | gp4c-0.0.21-cp311-cp311-macosx_14_0_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.11 macOS 14.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
ef5d3ed75120854927df30ae189744f2acf1e3af40518c80db97341a13c00474
|
|
BLAKE2b-256 checksum How to use checksums |
148973aad2fa22b7a87133edce2c3f5c9bda5acfd638d4004531643308593f13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp311-cp311-macosx_14_0_arm64.whl
| Download URL | gp4c-0.0.21-cp311-cp311-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.11 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3bbbe46ef93efb83710f9d3c5f11a2bc1044e7ea620f04e6ecba523bc03f658b
|
|
BLAKE2b-256 checksum How to use checksums |
a95e58c452ee95b416c20e4e00efc8159935bb6c612b1b5f112676498a0c45ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp310-cp310-manylinux_2_28_x86_64.whl
| Download URL | gp4c-0.0.21-cp310-cp310-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
e3c8ccdb574072cbb7a123a58320d14a01d6b8a8f0803c6b560c54597f8971ef
|
|
BLAKE2b-256 checksum How to use checksums |
774c0e7099f25418625103a1d45928e008090aa1a892b0ffa67580e5675b2c1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp310-cp310-macosx_14_0_x86_64.whl
| Download URL | gp4c-0.0.21-cp310-cp310-macosx_14_0_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.10 macOS 14.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
252d93e1903b47c96dce8714527020f0c01d3952ad005088d2be8c8036829465
|
|
BLAKE2b-256 checksum How to use checksums |
e5f6c3a5a86076f586d54d487af3c6914c260fbb7f382c3b93c17efcd78285ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp310-cp310-macosx_14_0_arm64.whl
| Download URL | gp4c-0.0.21-cp310-cp310-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.10 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1999ee8d36018aa544db09e67a696ac42b4fd8b446b5deb4e707f8363aa698e5
|
|
BLAKE2b-256 checksum How to use checksums |
33b004f4b8a6f47e61f93056f06e80d82aa7207f578f518d41be1f5535f175cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp39-cp39-manylinux_2_28_x86_64.whl
| Download URL | gp4c-0.0.21-cp39-cp39-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.9 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
f1ca1847f4ebf491a93d254fcc498da05c55014e42519d50b44a2cebaf9fe791
|
|
BLAKE2b-256 checksum How to use checksums |
4dd69609a12bb844463e2ebbb0c4eb041fad4885f9495fb9c3bbf84251f88ea0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp39-cp39-macosx_14_0_x86_64.whl
| Download URL | gp4c-0.0.21-cp39-cp39-macosx_14_0_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.9 macOS 14.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
47f8b68e8a1ccaaace77b3dc6e10acbb213b9c0d1bd84c6199b71d5b71c78450
|
|
BLAKE2b-256 checksum How to use checksums |
8d0e71b653f5539e42787a79a2af3e91ca0750c6467752e32812d8c9641be63d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / gp4c-0.0.21-cp39-cp39-macosx_14_0_arm64.whl
| Download URL | gp4c-0.0.21-cp39-cp39-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
13810d02d0bb649f043d98729fef9ccf2b26759bc6af0cea6dd11c0aadc9b2be
|
|
BLAKE2b-256 checksum How to use checksums |
54732cfb69886c065297c150ab7338dca194ae0093616fdb9bfc5a335a1a0313
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logSecurity for gp4c 0.0.21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 13 files in this release have been uploaded with provenance metadata.
Attestation for gp4c-0.0.21.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.