Metadata-Version: 2.4
Name: gaussianprocessderivatives
Version: 0.3.0
Summary: Use Gaussian processes to smooth data and estimate first- and second-order derivatives
License: MIT
Keywords: gaussian process,derivative
Author: Peter Swain
Requires-Python: >=3.11,<4.0
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Requires-Dist: matplotlib (>=3.10.6,<4.0.0)
Requires-Dist: numpy (>=2.3.3,<3.0.0)
Requires-Dist: scipy (>=1.16.2,<2.0.0)
Description-Content-Type: text/markdown

# Gaussianprocessderivatives
A Python package for smoothing data and estimating first- and
second-order derivatives and their errors. Covariance functions can be
linear, squared exponential, squared exponential with a linear trend,
twice-differentiable Matern, periodic, and locally periodic.

## Example
An example workflow to smooth data (x, y), where the columns of y are
replicates, is

```python
>>> import gaussianprocessderivatives as gp
>>> g = gp.maternGP({0: (-4, 4), 1: (-4, 4), 2: (-4, -2)}, x, y)
```

The dictionary sets bounds on the hyperparameters, so that 0: (-4, 4)
means that the bounds on the first hyperparameter are 1e-4 and 1e4.

The amplitude and measurement-error hyperparameters are variances of y,
so their bounds depend on the magnitude of the data. Passing
`scale_y=True` divides y by its root mean square before fitting while
restoring the units of the data in every prediction and sample, so that
one set of bounds serves data of most scales. The hyperparameters are
relative to the root-mean-square scale.

```python
>>> g.info()
```

explains what each hyperparameter does.

Once g is instantiated,

```python
>>> g.findhyperparameters()
>>> g.results()
>>> g.predict(x, derivs=2)
```

optimises the hyperparameters, determines a smoothed version of the
data, and estimates the derivatives.

The results can be visualised by

```python
>>> import matplotlib.pylab as plt
>>> plt.figure()
>>> plt.subplot(2, 1, 1)
>>> g.sketch('.')
>>> plt.subplot(2, 1, 2)
>>> g.sketch('.', derivs=1)
>>> plt.show()
```

and are available as `g.f` and `g.fvar` (smoothed data and error),
`g.df` and `g.dfvar` (estimate of dy/dx), and `g.ddf` and `g.ddfvar`
(estimate of d2y/dx2).

## Citation
If you find the software useful, please consider citing:

Swain, P. S., Stevenson, K., Leary, A., Montano-Gutierrez, L. F.,
Clark, I. B. N., Vogel, J., & Pilizota, T. (2016). Inferring time
derivatives including cell growth rates using Gaussian processes.
Nature Communications, 7, 13766.

## Development history
+ `v0.2.0`: Each covariance function became a class of its own; only
  for python 3.11; warnings from the Gaussian process are optional.
+ `v0.3.0`: `scale_y` introduced; the random-number generator now
  belongs to the instance, not to the module; a pytest suite added.

