Skip to main content

Fast joint GP sampling with integral and derivative relationships

Project description

logo 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)$ 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

All three 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
  • Three-way joint sampling of function, integral, and derivative
  • Posterior sampling conditioned on observed data
  • Mixed observations — observe f, predict h, or any combination
  • 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)

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)

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
│   ├── _sampler.c       # C implementation
│   ├── _core.pyx        # Cython wrapper
│   └── types.py         # Type definitions
├── docs/                # MkDocs documentation
├── tests/               # Test suite
├── examples/            # Example scripts
├── notebooks/           # Jupyter notebooks
└── mkdocs.yml           # Documentation config

Contributing

Contributions welcome! See Contributing Guide.

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. 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

  1. Solak et al. (2003) - Derivative observations in Gaussian process models
  2. Rasmussen & Williams (2006) - Gaussian Processes for Machine Learning
  3. GSL Manual - https://www.gnu.org/software/gsl/doc/html/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gp4c-0.0.11.tar.gz (151.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

gp4c-0.0.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

gp4c-0.0.11-cp312-cp312-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gp4c-0.0.11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

gp4c-0.0.11-cp311-cp311-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gp4c-0.0.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

gp4c-0.0.11-cp310-cp310-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

gp4c-0.0.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

gp4c-0.0.11-cp39-cp39-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file gp4c-0.0.11.tar.gz.

File metadata

  • Download URL: gp4c-0.0.11.tar.gz
  • Upload date:
  • Size: 151.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gp4c-0.0.11.tar.gz
Algorithm Hash digest
SHA256 53bb48a9b6b60f78f2102cf23ee587d632029e54d1ed75a85cddec75e01c0cd8
MD5 a7223bd8157a52700e3540c7cbc5f835
BLAKE2b-256 be6d3c72be9a9ffc3f719284111ad36f610aa660f78aba51069e381b1c3c49b7

See more details on using hashes here.

File details

Details for the file gp4c-0.0.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gp4c-0.0.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 818fd013fdbb30a5646a1dbd982e73a228b3493e8c1eafcb4a94269b7983b8a9
MD5 37ddf67e4a22ca71e9a07415c93d78d4
BLAKE2b-256 88dd1eb7f836b265f738036342ce70ae197b5fbcdb25a6466adba9dd80ddde22

See more details on using hashes here.

File details

Details for the file gp4c-0.0.11-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gp4c-0.0.11-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cb0656722ad02c37453823b2bebdb10c16c7ef766ce8ece1181e69614329d51f
MD5 0ad7e3eb551445358e78f8693161ea05
BLAKE2b-256 54cef6e9fed6472b2ffe8380b034a1ac86145190c74cfc16d1be22e9234495dc

See more details on using hashes here.

File details

Details for the file gp4c-0.0.11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gp4c-0.0.11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d5faec80b5aa3e04dfc78f44158cb85293242a9492a3dc28d49d27b3aad9d31a
MD5 6d837350617e2d342a57e2bc1701173c
BLAKE2b-256 8efec950d3b102248a5c66fb98421050d22ec24683e21cdc71195cdc43c2119b

See more details on using hashes here.

File details

Details for the file gp4c-0.0.11-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gp4c-0.0.11-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93dc0cdfe327bd4b3c2445e0a8cceaf3697a9591e23817f050650285bd731cb4
MD5 38433da295cd8d4f2673eea895eedb83
BLAKE2b-256 2282dad2a8212126aab869bafa1ed06e9e0d7f4fb88b3a021ca9bcaed5bb9f89

See more details on using hashes here.

File details

Details for the file gp4c-0.0.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gp4c-0.0.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52b70d22ce1de4b7d4d74afdb743fd4a8f11dcb932bd840cba6b91936baeca71
MD5 1b4c5f06e7c15268706be1e922667767
BLAKE2b-256 71ece2fe56f50feec58578fb2319c853c903804b317475c00326c07e4482d9dc

See more details on using hashes here.

File details

Details for the file gp4c-0.0.11-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gp4c-0.0.11-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 04e572987d10f23c452c73ea44917552e4226ba6c8d950ca805e58df13717748
MD5 856324daa25a95658e11678e7a55eed0
BLAKE2b-256 2fb4f4b6caaef7dd51b5a6057d526124d5a913df7b04fbe596fb0ca5ce7c5d95

See more details on using hashes here.

File details

Details for the file gp4c-0.0.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gp4c-0.0.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 58202a5b6a7fc190ccdecd63c472d41b6be60bba30497364f973ba773969c0ee
MD5 186d42d444884f506d6097b7807d61f7
BLAKE2b-256 3cd4582eae7e04c80f005a6f163eb99e49916ce6a3ee45a46ae76ee0cc092ae1

See more details on using hashes here.

File details

Details for the file gp4c-0.0.11-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gp4c-0.0.11-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 43abcf67ff92022f60dea85c7690916c27457a8155f8f5417b06e25fcf3f8f87
MD5 f1a0868063a16a15d9114c01b17be4fc
BLAKE2b-256 24ad42e1ae7c401001be1bbad802c30b553c9aa03f8747c6af923217d9277c32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page