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.12.tar.gz (166.3 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.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

gp4c-0.0.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

gp4c-0.0.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

gp4c-0.0.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

gp4c-0.0.12-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.12.tar.gz.

File metadata

  • Download URL: gp4c-0.0.12.tar.gz
  • Upload date:
  • Size: 166.3 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.12.tar.gz
Algorithm Hash digest
SHA256 df8789c84609ff4f24f45cb1bc6a9ee0dd17905d5b0b96ed58cd402bd0ca3659
MD5 284ea1acb76c3624778cc150f026ccfd
BLAKE2b-256 ed1627b3705a17de1fd13c0f55ccaf7defe7d1172a1949de60ca89e425aae70f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aa014b3d110200a0999a7e8e7327ed2f2119a14431ca6a1e87bd75b9b4cd670e
MD5 a8eedb6beed96d103bad1fe50bf60ebb
BLAKE2b-256 15b58bd3f396121ebf9887b51edf50182eaad3011b8ddf1bfaaec70c37fe0d54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 34114d652391d7091837ede489562622cfaf29ae1ee6386059a1bb044490c237
MD5 7c19fad88519f43e1e6b790cf1bae01c
BLAKE2b-256 75a76bb212679c894c16704cdf346eff6fa880dd3e50301d40cf76465df4e59a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0640ee6fb6a4794ddd46bfe5b35c2bf1f6c24c0474be62f8bc97e827ea86b796
MD5 df67974827bfcd4fd5665a42d9b7099f
BLAKE2b-256 e8a40d146baec4920ff7b9164e2b6b42cd5f8400f7ee44a7524ed053d0986222

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.12-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4bd63d2ce7f99c3cba8ff25daae4a15278bd712282c0cccc64c45cc7368a820b
MD5 9b3a616860f7f6769d8df21a5b6a4c4f
BLAKE2b-256 2ab954d6ad34c894527b26dce469f3dc6c335fdf51b4dcc7985671c019600838

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 28f60b7b15d6a39a0e74d9c430d91faa7d19790ff07ca5bff453e2336e24616c
MD5 24fd8fa249fb4988e7ecedbd6f53beae
BLAKE2b-256 ea7bff4ae0e18fe5f22e20b1323878f451d592a709aa9019060dc6d39fcbc900

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.12-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f93fd6660508fd93f7b8d7308ef2f3e066b5bda0a73e98209ed1c9ed583406ac
MD5 f7e0ba65417be3ba3f0c806437e5bf8d
BLAKE2b-256 3f6759a38fe1ef248a696b8c73048731c832a74fe5dbdc6c2b5b50954d6f70b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3364c2d8ae4ad63486495068235c54ff9d82277e466eb4dc63a422b6e83be0f6
MD5 c562f59989288c3279ff778e3d396366
BLAKE2b-256 c7a54dba72a1b63a3ac74543e424f78803aaf368d1009e2bafc5d9bb3dd0b523

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.12-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f0354ef3f3cdf3634155ac26593d1527703bd41e4cb1069371d3640c0487bca
MD5 e29d8b34edd5ba8c29b99e1579f6db02
BLAKE2b-256 e49e6eb68683da7afc6583b549d6ebab3dd54c2b8d06a9cd0387f261f6ecb9c7

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