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.13.tar.gz (204.0 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.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

gp4c-0.0.13-cp312-cp312-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gp4c-0.0.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

gp4c-0.0.13-cp311-cp311-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gp4c-0.0.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

gp4c-0.0.13-cp310-cp310-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

gp4c-0.0.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

gp4c-0.0.13-cp39-cp39-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: gp4c-0.0.13.tar.gz
  • Upload date:
  • Size: 204.0 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.13.tar.gz
Algorithm Hash digest
SHA256 fb10ff17d07495b5da24f9a2b23ae8b5ea20550012da863212a77791ecb21997
MD5 78df26c29df1d02442418e03f56153be
BLAKE2b-256 d66da3d27e5f7bcce1a597fb68b3872a79f18a0b64f4b41fee6e7ea4c6a51f8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 944b543640c80c97414e650975b8a580bdd5da9d45631311fd5c4d31c53fbbf3
MD5 5cf097061bab4bced08fa4aff4966dc3
BLAKE2b-256 b57960d6a91d51ca3425e87282f88f942cece3612dc45b76d0434573b1f4ede3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eac458faa7ce830a0fa697813f5904f55ba634b23a25e4eb065c8e899ebb7cfa
MD5 991b6ffd5977f9dc896e8bed455300dc
BLAKE2b-256 ae1c7613a4770085b42360026fc9d5ee7533f3539d944db3b4e20a0ec5aea940

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9e35dfd132e28b2a467230c56a73808d06cbc9d54c7fb963206bcf7556e05de1
MD5 74aeb5dc0625844285bddd351ee002ed
BLAKE2b-256 2e58cbc51e6118798ef4895369610478d5d0345dbc2e007435ae593c7daa85e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.13-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 63070aee18f80ab7f1995142e2a43ff37d46c680dc3805bcf2462944ac84927a
MD5 31beea116101f23800cdf13b00b956eb
BLAKE2b-256 ac51b6080e89ccc21bb51f65f1bacf8aeab032488f9030ded5ad04db2b02b937

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 57b79371ca8892e154109054efaa42b2a38608044eae645d5da87c1e24ae38e4
MD5 ad747ab279ba1da1dd53931fdadf6e21
BLAKE2b-256 d1ea1d4574f6f268c122f1bb93e6936eb2e3c19cd8b86a990bcf5d424f4451b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.13-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 21a8d9cd84e9051620a1d31b97b48c7792eeb55d98c48d7402cc882597e65a32
MD5 350f61bbcabb7da9f01d8b1f0455433c
BLAKE2b-256 1711729d85e159c502b5be3170becfacd45f53244cc3235b1431b8f73d91fcdf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 396466a637d687627c0c2a0811a957bbd40cc9e5dab02747108d425acd9171e9
MD5 950a3b06b1470d32e16ac4b46a3e124c
BLAKE2b-256 b32169811c5129041c4d3fbd8786e216c9ffba0abe3ed9133d97609f7ac41b68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gp4c-0.0.13-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8a1b7d8fe87ae13e377a007064323050a5ce535667a6bf96a682f3250013273
MD5 dd7ef8f6c3f7f47b9885ac44a3269faa
BLAKE2b-256 c27fa4facd2480f48637386ba50efd6fae2f44fe37a24b42820acb5f46dd04f2

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