You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following is an example showing how to specify a simple model with a GP prior using the {class}`gp.Latent` class. We use a GP to generate the data so we can verify that the inference we perform is correct. Note that the likelihood is not normal, but IID Student-T. For a more efficient implementation when the likelihood is Gaussian, use {class}`gp.Marginal`.
82
85
86
+
:::{include} ../extra_installs.md
87
+
:::
88
+
83
89
```{code-cell} ipython3
84
90
import arviz as az
85
91
import matplotlib.pyplot as plt
@@ -158,7 +164,7 @@ with pm.Model() as model:
158
164
) # add one because student t is undefined for degrees of freedom less than one
Copy file name to clipboardExpand all lines: examples/gaussian_processes/GP-Marginal.myst.md
+60-38
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,15 @@ kernelspec:
10
10
name: python3
11
11
---
12
12
13
+
(gp_marginal)=
13
14
# Marginal Likelihood Implementation
14
15
16
+
:::{post} June 4, 2023
17
+
:tags: gaussian processes, time series
18
+
:category: reference, intermediate
19
+
:author: Bill Engels, Chris Fonnesbeck
20
+
:::
21
+
15
22
The `gp.Marginal` class implements the more common case of GP regression: the observed data are the sum of a GP and Gaussian noise. `gp.Marginal` has a `marginal_likelihood` method, a `conditional` method, and a `predict` method. Given a mean and covariance function, the function $f(x)$ is modeled as,
16
23
17
24
$$
@@ -68,19 +75,19 @@ with pm.Model() as marginal_gp_model:
68
75
69
76
# The scale of the white noise term can be provided,
The `.conditional` has an optional flag for `pred_noise`, which defaults to `False`. When `pred_noise=False`, the `conditional` method produces the predictive distribution for the underlying function represented by the GP. When `pred_noise=True`, the `conditional` method produces the predictive distribution for the GP plus noise. Using the same `gp` object defined above,
90
+
The `.conditional` has an optional flag for `pred_noise`, which defaults to `False`. When `pred_sigma=False`, the `conditional` method produces the predictive distribution for the underlying function represented by the GP. When `pred_sigma=True`, the `conditional` method produces the predictive distribution for the GP plus noise. Using the same `gp` object defined above,
84
91
85
92
```python
86
93
# vector of new X points we want to predict the function at
If using an additive GP model, the conditional distribution for individual components can be constructed by setting the optional argument `given`. For more information on building additive GPs, see the main documentation page. For an example, see the Mauna Loa CO$_2$ notebook.
plt.plot(X, y, "ok", ms=3, alpha=1.0, label="observed data")
@@ -268,18 +276,21 @@ Notice that the posterior predictive density is wider than the conditional distr
268
276
269
277
### Using `.predict`
270
278
271
-
We can use the `.predict` method to return the mean and variance given a particular `point`. Since we used `find_MAP` in this example, `predict` returns the same mean and covariance that the distribution of `.conditional` has.
279
+
We can use the `.predict` method to return the mean and variance given a particular `point`.
0 commit comments