gp4c 0.0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
gp4c-0.0.9/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rodrigo Calderon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
gp4c-0.0.9/MANIFEST.in ADDED
@@ -0,0 +1,25 @@
1
+ # Include Cython source files
2
+ include gp4c/_core.pyx
3
+ include gp4c/_core.c
4
+
5
+ # Include C library files
6
+ include gp4c/gp4c.c
7
+ include gp4c/gp4c.h
8
+
9
+ # Include installation script
10
+ include install_library.sh
11
+
12
+ # Include documentation
13
+ include README.md
14
+ include LICENSE
15
+
16
+ # Include test data if any
17
+ recursive-include tests *.py
18
+
19
+ # Include examples
20
+ recursive-include examples *.py *.c Makefile
21
+
22
+ # Exclude build artifacts
23
+ global-exclude __pycache__
24
+ global-exclude *.py[co]
25
+ global-exclude .DS_Store
gp4c-0.0.9/PKG-INFO ADDED
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.4
2
+ Name: gp4c
3
+ Version: 0.0.9
4
+ Summary: Fast joint GP sampling with integral and derivative relationships
5
+ Author-email: Rodrigo Calderon <calderon.cosmology@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/rcalderonb6/gp4c
8
+ Project-URL: Documentation, https://github.com/rcalderonb6/gp4c#readme
9
+ Project-URL: Repository, https://github.com/rcalderonb6/gp4c
10
+ Project-URL: Issues, https://github.com/rcalderonb6/gp4c/issues
11
+ Keywords: gaussian-process,gp,sampling,integral,derivative,bayesian
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Cython
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.21
26
+ Requires-Dist: typer>=0.9.0
27
+ Requires-Dist: rich>=13.0.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7.0; extra == "dev"
30
+ Requires-Dist: matplotlib>=3.5; extra == "dev"
31
+ Requires-Dist: ipython; extra == "dev"
32
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
33
+ Requires-Dist: codespell>=2.2.0; extra == "dev"
34
+ Requires-Dist: bump-my-version>=0.26.0; extra == "dev"
35
+ Provides-Extra: viz
36
+ Requires-Dist: matplotlib>=3.5; extra == "viz"
37
+ Requires-Dist: seaborn>=0.12; extra == "viz"
38
+ Provides-Extra: docs
39
+ Requires-Dist: mkdocs<2.0,>=1.5; extra == "docs"
40
+ Requires-Dist: mkdocs-material>=9.0; extra == "docs"
41
+ Requires-Dist: mkdocs-marimo>=0.1.0; extra == "docs"
42
+ Requires-Dist: mkdocstrings[python]>=0.27.0; extra == "docs"
43
+ Requires-Dist: pymdown-extensions>=10.0; extra == "docs"
44
+ Requires-Dist: codespell>=2.2.0; extra == "docs"
45
+ Dynamic: license-file
46
+
47
+ # gp4c
48
+
49
+ High-performance C implementation with Python bindings for sampling from joint Gaussian Processes with integral and derivative relationships.
50
+
51
+ ## Overview
52
+
53
+ Sample from joint GP $(f, g, h)$ where:
54
+
55
+ - $f(x) \sim \mathcal{GP}(0, k_f)$ — original process with RBF kernel
56
+ - $g(x) = \int_0^x f(t) dt$ — integrated process
57
+ - $h(x) = f'(x)$ — derivative process
58
+
59
+ All three are correlated through proper cross-covariance structures.
60
+
61
+ ## Key Features
62
+
63
+ - **Fast C implementation** using GSL (GNU Scientific Library)
64
+ - **Zero-copy Cython wrapper** for seamless NumPy integration
65
+ - **Three-way joint sampling** of function, integral, and derivative
66
+ - **Posterior sampling** conditioned on observed data
67
+ - **Mixed observations** — observe f, predict h, or any combination
68
+ - **Mathematically rigorous** covariance structure
69
+ - **Fully tested** with comprehensive unit tests
70
+
71
+ ## Quick Install
72
+
73
+ ### Prerequisites
74
+
75
+ Install GSL first:
76
+
77
+ ```bash
78
+ # macOS
79
+ brew install gsl
80
+
81
+ # Ubuntu/Debian
82
+ sudo apt-get install libgsl-dev
83
+
84
+ # Fedora/RHEL
85
+ sudo dnf install gsl-devel
86
+ ```
87
+
88
+ ### Install Package
89
+
90
+ ```bash
91
+ pip install -e .
92
+ ```
93
+
94
+ ## Quick Start
95
+
96
+ ```python
97
+ import numpy as np
98
+ from gp4c import sample_joint_gp
99
+
100
+ x = np.linspace(0, 5, 100)
101
+ f_samples, g_samples = sample_joint_gp(
102
+ x, x,
103
+ sigma2=1.0,
104
+ ell=0.5,
105
+ n_samples=5,
106
+ seed=42
107
+ )
108
+ ```
109
+
110
+ ## Documentation
111
+
112
+ Full documentation is available at: **[https://yourusername.github.io/gp4c](https://yourusername.github.io/gp4c)**
113
+
114
+ Or build locally:
115
+
116
+ ```bash
117
+ pip install mkdocs-material
118
+ mkdocs serve
119
+ ```
120
+
121
+ ### Quick Links
122
+
123
+ - [Installation Guide](https://yourusername.github.io/gp4c/getting-started/installation/)
124
+ - [Quick Start Tutorial](https://yourusername.github.io/gp4c/getting-started/quickstart/)
125
+ - [API Reference](https://yourusername.github.io/gp4c/api/functions/)
126
+ - [Mathematical Background](https://yourusername.github.io/gp4c/math/kernels/)
127
+ - [Examples](https://yourusername.github.io/gp4c/examples/python/)
128
+
129
+ ## Examples
130
+
131
+ Basic usage:
132
+
133
+ ```python
134
+ # Sample f and its derivative h
135
+ from gp4c import sample_gp, SamplingSpec
136
+
137
+ spec = SamplingSpec(x_f=x, x_h=x)
138
+ result = sample_gp(spec, sigma2=1.0, ell=0.5, n_samples=5)
139
+ ```
140
+
141
+ Posterior sampling:
142
+
143
+ ```python
144
+ # Condition on observations
145
+ from gp4c import sample_gp_posterior, Observations
146
+
147
+ x_train = np.array([0.0, 1.0, 2.0, 3.0, 4.0])
148
+ y_train = np.sin(x_train)
149
+ obs = Observations(x_f=x_train, y_f=y_train, noise_f=0.01)
150
+
151
+ x_test = np.linspace(0, 5, 100)
152
+ spec = SamplingSpec(x_f=x_test)
153
+
154
+ result = sample_gp_posterior(obs, spec, ell=1.0, n_samples=10)
155
+ ```
156
+
157
+ See the [examples/](examples/) directory and [documentation](https://yourusername.github.io/gp4c/examples/python/) for more.
158
+
159
+ ## Testing
160
+
161
+ ```bash
162
+ pytest tests/ -v
163
+ ```
164
+
165
+ ## C Library
166
+
167
+ The core can be used directly in C/C++ projects. See [C Integration Guide](https://yourusername.github.io/gp4c/examples/c-integration/).
168
+
169
+ Quick install as system library:
170
+
171
+ ```bash
172
+ ./install_library.sh # System-wide (requires sudo)
173
+ ./install_library.sh --user # User install (no sudo)
174
+ ```
175
+
176
+ ## Project Structure
177
+
178
+ ```
179
+ gp4c/
180
+ ├── gp4c/ # Python package
181
+ │ ├── _sampler.c # C implementation
182
+ │ ├── _core.pyx # Cython wrapper
183
+ │ └── types.py # Type definitions
184
+ ├── docs/ # MkDocs documentation
185
+ ├── tests/ # Test suite
186
+ ├── examples/ # Example scripts
187
+ ├── notebooks/ # Jupyter notebooks
188
+ └── mkdocs.yml # Documentation config
189
+ ```
190
+
191
+ ## Contributing
192
+
193
+ Contributions welcome! See [Contributing Guide](https://yourusername.github.io/gp4c/reference/contributing/).
194
+
195
+ 1. Fork the repository
196
+ 2. Create a feature branch
197
+ 3. Add tests for new functionality
198
+ 4. Submit a pull request
199
+
200
+ ## License
201
+
202
+ MIT License - see LICENSE file for details.
203
+
204
+ ## Citation
205
+
206
+ If you use this package in your research, please cite:
207
+
208
+ ```bibtex
209
+ @software{gp4c,
210
+ title = {gp4c: Fast Joint Gaussian Process Sampling with integral and derivative information},
211
+ author = {Calderón, Rodrigo},
212
+ year = {2026},
213
+ url = {https://github.com/rcalderonb6/gp4c}
214
+ }
215
+ ```
216
+
217
+ ## References
218
+
219
+ 1. Solak et al. (2003) - Derivative observations in Gaussian process models
220
+ 2. Rasmussen & Williams (2006) - Gaussian Processes for Machine Learning
221
+ 3. GSL Manual - https://www.gnu.org/software/gsl/doc/html/
gp4c-0.0.9/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # gp4c
2
+
3
+ High-performance C implementation with Python bindings for sampling from joint Gaussian Processes with integral and derivative relationships.
4
+
5
+ ## Overview
6
+
7
+ Sample from joint GP $(f, g, h)$ where:
8
+
9
+ - $f(x) \sim \mathcal{GP}(0, k_f)$ — original process with RBF kernel
10
+ - $g(x) = \int_0^x f(t) dt$ — integrated process
11
+ - $h(x) = f'(x)$ — derivative process
12
+
13
+ All three are correlated through proper cross-covariance structures.
14
+
15
+ ## Key Features
16
+
17
+ - **Fast C implementation** using GSL (GNU Scientific Library)
18
+ - **Zero-copy Cython wrapper** for seamless NumPy integration
19
+ - **Three-way joint sampling** of function, integral, and derivative
20
+ - **Posterior sampling** conditioned on observed data
21
+ - **Mixed observations** — observe f, predict h, or any combination
22
+ - **Mathematically rigorous** covariance structure
23
+ - **Fully tested** with comprehensive unit tests
24
+
25
+ ## Quick Install
26
+
27
+ ### Prerequisites
28
+
29
+ Install GSL first:
30
+
31
+ ```bash
32
+ # macOS
33
+ brew install gsl
34
+
35
+ # Ubuntu/Debian
36
+ sudo apt-get install libgsl-dev
37
+
38
+ # Fedora/RHEL
39
+ sudo dnf install gsl-devel
40
+ ```
41
+
42
+ ### Install Package
43
+
44
+ ```bash
45
+ pip install -e .
46
+ ```
47
+
48
+ ## Quick Start
49
+
50
+ ```python
51
+ import numpy as np
52
+ from gp4c import sample_joint_gp
53
+
54
+ x = np.linspace(0, 5, 100)
55
+ f_samples, g_samples = sample_joint_gp(
56
+ x, x,
57
+ sigma2=1.0,
58
+ ell=0.5,
59
+ n_samples=5,
60
+ seed=42
61
+ )
62
+ ```
63
+
64
+ ## Documentation
65
+
66
+ Full documentation is available at: **[https://yourusername.github.io/gp4c](https://yourusername.github.io/gp4c)**
67
+
68
+ Or build locally:
69
+
70
+ ```bash
71
+ pip install mkdocs-material
72
+ mkdocs serve
73
+ ```
74
+
75
+ ### Quick Links
76
+
77
+ - [Installation Guide](https://yourusername.github.io/gp4c/getting-started/installation/)
78
+ - [Quick Start Tutorial](https://yourusername.github.io/gp4c/getting-started/quickstart/)
79
+ - [API Reference](https://yourusername.github.io/gp4c/api/functions/)
80
+ - [Mathematical Background](https://yourusername.github.io/gp4c/math/kernels/)
81
+ - [Examples](https://yourusername.github.io/gp4c/examples/python/)
82
+
83
+ ## Examples
84
+
85
+ Basic usage:
86
+
87
+ ```python
88
+ # Sample f and its derivative h
89
+ from gp4c import sample_gp, SamplingSpec
90
+
91
+ spec = SamplingSpec(x_f=x, x_h=x)
92
+ result = sample_gp(spec, sigma2=1.0, ell=0.5, n_samples=5)
93
+ ```
94
+
95
+ Posterior sampling:
96
+
97
+ ```python
98
+ # Condition on observations
99
+ from gp4c import sample_gp_posterior, Observations
100
+
101
+ x_train = np.array([0.0, 1.0, 2.0, 3.0, 4.0])
102
+ y_train = np.sin(x_train)
103
+ obs = Observations(x_f=x_train, y_f=y_train, noise_f=0.01)
104
+
105
+ x_test = np.linspace(0, 5, 100)
106
+ spec = SamplingSpec(x_f=x_test)
107
+
108
+ result = sample_gp_posterior(obs, spec, ell=1.0, n_samples=10)
109
+ ```
110
+
111
+ See the [examples/](examples/) directory and [documentation](https://yourusername.github.io/gp4c/examples/python/) for more.
112
+
113
+ ## Testing
114
+
115
+ ```bash
116
+ pytest tests/ -v
117
+ ```
118
+
119
+ ## C Library
120
+
121
+ The core can be used directly in C/C++ projects. See [C Integration Guide](https://yourusername.github.io/gp4c/examples/c-integration/).
122
+
123
+ Quick install as system library:
124
+
125
+ ```bash
126
+ ./install_library.sh # System-wide (requires sudo)
127
+ ./install_library.sh --user # User install (no sudo)
128
+ ```
129
+
130
+ ## Project Structure
131
+
132
+ ```
133
+ gp4c/
134
+ ├── gp4c/ # Python package
135
+ │ ├── _sampler.c # C implementation
136
+ │ ├── _core.pyx # Cython wrapper
137
+ │ └── types.py # Type definitions
138
+ ├── docs/ # MkDocs documentation
139
+ ├── tests/ # Test suite
140
+ ├── examples/ # Example scripts
141
+ ├── notebooks/ # Jupyter notebooks
142
+ └── mkdocs.yml # Documentation config
143
+ ```
144
+
145
+ ## Contributing
146
+
147
+ Contributions welcome! See [Contributing Guide](https://yourusername.github.io/gp4c/reference/contributing/).
148
+
149
+ 1. Fork the repository
150
+ 2. Create a feature branch
151
+ 3. Add tests for new functionality
152
+ 4. Submit a pull request
153
+
154
+ ## License
155
+
156
+ MIT License - see LICENSE file for details.
157
+
158
+ ## Citation
159
+
160
+ If you use this package in your research, please cite:
161
+
162
+ ```bibtex
163
+ @software{gp4c,
164
+ title = {gp4c: Fast Joint Gaussian Process Sampling with integral and derivative information},
165
+ author = {Calderón, Rodrigo},
166
+ year = {2026},
167
+ url = {https://github.com/rcalderonb6/gp4c}
168
+ }
169
+ ```
170
+
171
+ ## References
172
+
173
+ 1. Solak et al. (2003) - Derivative observations in Gaussian process models
174
+ 2. Rasmussen & Williams (2006) - Gaussian Processes for Machine Learning
175
+ 3. GSL Manual - https://www.gnu.org/software/gsl/doc/html/
@@ -0,0 +1,45 @@
1
+ # Makefile for GP Sampler C Examples
2
+ #
3
+ # Usage:
4
+ # make # Build the C example
5
+ # make run # Build and run
6
+ # make clean # Remove build artifacts
7
+
8
+ CC = gcc
9
+ CFLAGS = -O3 -Wall -Wextra $(shell gsl-config --cflags)
10
+ LDFLAGS = $(shell gsl-config --libs) -lm
11
+
12
+ # Directories
13
+ SRC_DIR = ..
14
+ INCLUDES = -I$(SRC_DIR)
15
+
16
+ # Targets
17
+ TARGET = c_example
18
+ SOURCES = c_integration_example.c $(SRC_DIR)/gp_sampler_core.c
19
+ OBJECTS = $(SOURCES:.c=.o)
20
+ HEADERS = $(SRC_DIR)/gp_sampler_core.h
21
+
22
+ # Build rules
23
+ all: $(TARGET)
24
+
25
+ $(TARGET): $(OBJECTS)
26
+ $(CC) -o $@ $^ $(LDFLAGS)
27
+ @echo "Build successful! Run with: ./$(TARGET)"
28
+
29
+ %.o: %.c $(HEADERS)
30
+ $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
31
+
32
+ run: $(TARGET)
33
+ ./$(TARGET)
34
+
35
+ clean:
36
+ rm -f $(OBJECTS) $(TARGET)
37
+ rm -f $(SRC_DIR)/gp_sampler_core.o
38
+ @echo "Cleaned build artifacts"
39
+
40
+ # Static library (optional)
41
+ libgp4c.a: $(SRC_DIR)/gp_sampler_core.o
42
+ ar rcs $@ $^
43
+ @echo "Created static library: libgp4c.a"
44
+
45
+ .PHONY: all run clean
@@ -0,0 +1,37 @@
1
+ """gp4c - Fast joint GP sampling with integral and derivative relationships.
2
+
3
+ This package provides efficient sampling from joint Gaussian Processes where:
4
+ - f(x) is a GP with RBF kernel
5
+ - g(x) = integral of f from 0 to x
6
+ - h(x) = f'(x), the derivative
7
+
8
+ All functions maintain exact covariance structure through analytically-derived
9
+ cross-covariance kernels.
10
+ """
11
+
12
+ from ._core import (
13
+ sample_joint_gp,
14
+ sample_gp,
15
+ sample_and_integrate,
16
+ sample_gp_posterior,
17
+ )
18
+ from .types import (
19
+ MeanSpec,
20
+ SamplingSpec,
21
+ GPSamples,
22
+ Observations,
23
+ PosteriorSamples,
24
+ )
25
+
26
+ __version__ = "2.0.0"
27
+ __all__ = [
28
+ "sample_joint_gp",
29
+ "sample_gp",
30
+ "sample_and_integrate",
31
+ "sample_gp_posterior",
32
+ "MeanSpec",
33
+ "SamplingSpec",
34
+ "GPSamples",
35
+ "Observations",
36
+ "PosteriorSamples",
37
+ ]