# Path: rbf/gproc.py
# def gpiso(phi, eps, var, dim=None):
#     '''
#     Creates an isotropic Gaussian process which has a covariance function that
#     is described by a radial basis function.
# 
#     Parameters
#     ----------
#     phi : str or RBF instance
#         Radial basis function describing the covariance function.
# 
#     eps : float
#         Shape parameter.
# 
#     var : float
#         Variance.
# 
#     dim : int, optional
#         Fixes the spatial dimensions of the domain.
# 
#     Returns
#     -------
#     GaussianProcess
# 
#     Notes
#     -----
#     Not all radial basis functions are positive definite, which means that it
#     is possible to instantiate an invalid `GaussianProcess`. The method
#     `is_positive_definite` provides a necessary but not sufficient test for
#     positive definiteness. Examples of predefined `RBF` instances which are
#     positive definite include: `rbf.basis.se`, `rbf.basis.ga`, `rbf.basis.exp`,
#     `rbf.basis.iq`, `rbf.basis.imq`.
# 
#     '''
#     phi = rbf.basis.get_rbf(phi)
# 
#     def isotropic_covariance(x1, x2, diff1, diff2):
#         diff = diff1 + diff2
#         coeff = var*(-1)**sum(diff2)
#         out = coeff*phi(x1, x2, eps=eps, diff=diff)
#         return out
# 
#     def isotropic_variance(x, diff):
#         coeff = var*(-1)**sum(diff)
#         value = coeff*phi.center_value(eps=eps, diff=2*diff)
#         out = np.full(x.shape[0], value)
#         return out
# 
#     out = GaussianProcess(
#         covariance=isotropic_covariance,
#         variance=isotropic_variance,
#         dim=dim,
#         differentiable=True
#         )
#     return out


import numpy as np
import matplotlib.pyplot as plt
from rbf.gproc import gpiso
''' 
This script demonstrates how to make a custom *GaussianProcess* by 
combining *GaussianProcess* instances. The resulting Gaussian process 
has two distinct length-scales.
'''
np.random.seed(1)

dx = np.linspace(0.0, 5.0, 1000)[:, None]
x = np.linspace(-5, 5.0, 1000)[:, None]
gp_long = gpiso('se', eps=2.0, var=1.0)

# Path: rbf/gproc.py
# def gpiso(phi, eps, var, dim=None):
#     '''
#     Creates an isotropic Gaussian process which has a covariance function that
#     is described by a radial basis function.
# 
#     Parameters
#     ----------
#     phi : str or RBF instance
#         Radial basis function describing the covariance function.
# 
#     eps : float
#         Shape parameter.
# 
#     var : float
#         Variance.
# 
#     dim : int, optional
#         Fixes the spatial dimensions of the domain.
# 
#     Returns
#     -------
#     GaussianProcess
# 
#     Notes
#     -----
#     Not all radial basis functions are positive definite, which means that it
#     is possible to instantiate an invalid `GaussianProcess`. The method
#     `is_positive_definite` provides a necessary but not sufficient test for
#     positive definiteness. Examples of predefined `RBF` instances which are
#     positive definite include: `rbf.basis.se`, `rbf.basis.ga`, `rbf.basis.exp`,
#     `rbf.basis.iq`, `rbf.basis.imq`.
# 
#     '''
#     phi = rbf.basis.get_rbf(phi)
# 
#     def isotropic_covariance(x1, x2, diff1, diff2):
#         diff = diff1 + diff2
#         coeff = var*(-1)**sum(diff2)
#         out = coeff*phi(x1, x2, eps=eps, diff=diff)
#         return out
# 
#     def isotropic_variance(x, diff):
#         coeff = var*(-1)**sum(diff)
#         value = coeff*phi.center_value(eps=eps, diff=2*diff)
#         out = np.full(x.shape[0], value)
#         return out
# 
#     out = GaussianProcess(
#         covariance=isotropic_covariance,
#         variance=isotropic_variance,
#         dim=dim,
#         differentiable=True
#         )
#     return out


# Path: docs/scripts/gproc.b.py
import numpy as np
import matplotlib.pyplot as plt
from rbf.gproc import gpiso

''' 
This script demonstrates how to make a custom *GaussianProcess* by 
combining *GaussianProcess* instances. The resulting Gaussian process 
has two distinct length-scales.
'''
np.random.seed(1)

dx = np.linspace(0.0, 5.0, 1000)[:, None]
x = np.linspace(-5, 5.0, 1000)[:, None]
gp_long = gpiso('se', eps=2.0, var=1.0)

gp_short = gpiso('se', eps=0.25, var=0.5)