Bases: Kernel
Noise kernel class for Gaussian Processes (GPs).
The Noise
class defines a kernel that models the nugget effect, which represents uncorrelated noise
in the data. It produces a diagonal covariance matrix with the specified nugget
value, indicating
the presence of noise at each location.
Parameters:
-
nugget
(float or Variable
)
–
The variance (nugget) representing the noise level. This value is added to the diagonal
of the covariance matrix.
Examples:
Creating and using a Noise
kernel:
from geostat.kernel import Noise
# Create a Noise kernel with a nugget value of 0.1
noise_kernel = Noise(nugget=0.1)
locs1 = np.array([[0.0], [1.0], [2.0]])
locs2 = np.array([[0.0], [1.0], [2.0]])
covariance_matrix = noise_kernel({'locs1': locs1, 'locs2': locs2, 'nugget': 0.1})
Notes:
- The
call
method computes a diagonal covariance matrix where the diagonal elements are equal
to nugget
, representing noise at each location. Off-diagonal elements are set to 0.
- The
vars
method returns the parameter dictionary for nugget
using the ppp
function.
- The
Noise
kernel is useful for modeling independent noise in the data, especially when the
observations contain measurement error or variability that cannot be explained by the model.
Source code in src/geostat/kernel.py
| class Noise(Kernel):
"""
Noise kernel class for Gaussian Processes (GPs).
The `Noise` class defines a kernel that models the nugget effect, which represents uncorrelated noise
in the data. It produces a diagonal covariance matrix with the specified `nugget` value, indicating
the presence of noise at each location.
Parameters:
nugget (float or tf.Variable):
The variance (nugget) representing the noise level. This value is added to the diagonal
of the covariance matrix.
Examples:
Creating and using a `Noise` kernel:
```python
from geostat.kernel import Noise
# Create a Noise kernel with a nugget value of 0.1
noise_kernel = Noise(nugget=0.1)
locs1 = np.array([[0.0], [1.0], [2.0]])
locs2 = np.array([[0.0], [1.0], [2.0]])
covariance_matrix = noise_kernel({'locs1': locs1, 'locs2': locs2, 'nugget': 0.1})
```
Examples: Notes:
- The `call` method computes a diagonal covariance matrix where the diagonal elements are equal
to `nugget`, representing noise at each location. Off-diagonal elements are set to 0.
- The `vars` method returns the parameter dictionary for `nugget` using the `ppp` function.
- The `Noise` kernel is useful for modeling independent noise in the data, especially when the
observations contain measurement error or variability that cannot be explained by the model.
"""
def __init__(self, nugget):
fa = dict(nugget=nugget)
super().__init__(fa, dict(locs1='locs1', locs2='locs2'))
def vars(self):
return ppp(self.fa['nugget'])
def call(self, e):
indices1 = tf.range(tf.shape(e['locs1'])[0])
indices2 = tf.range(tf.shape(e['locs2'])[0]) + e['offset']
C = tf.where(tf.equal(tf.expand_dims(indices1, -1), indices2), e['nugget'], 0.)
return C
|