Bases: Kernel
QuadStack kernel class for Gaussian Processes (GPs).
The QuadStack
class defines a kernel that combines multiple quadratic components to model complex
covariance structures. It allows for multiple sills and ranges, providing flexibility in capturing
covariance that varies across different scales.
Parameters:
-
range
(list or Variable
)
–
A list or TensorFlow variable representing the length scale parameters that control how
quickly the covariance decreases with distance.
-
sill
(list or Variable
)
–
A list or TensorFlow variable representing the variance (sill) values for each quadratic component.
-
scale
(optional
, default:
None
)
–
An optional scale parameter that can be used to modify the metric. Default is None.
-
metric
(optional
, default:
None
)
–
An optional metric used for distance calculation. Default is None.
Examples:
Creating and using a QuadStack
kernel:
from geostat.kernel import QuadStack
# Create a QuadStack kernel with multiple sills and ranges
quad_stack_kernel = QuadStack(range=[2.0, 3.0], sill=[1.0, 0.5])
locs1 = np.array([[0.0], [1.0], [2.0]])
locs2 = np.array([[0.0], [1.0], [2.0]])
covariance_matrix = quad_stack_kernel({'locs1': locs1, 'locs2': locs2, 'sill': [1.0, 0.5], 'range': [2.0, 3.0]})
Notes:
- The
call
method computes the covariance matrix using the quadstack
function, which applies
multiple quadratic functions based on the provided sill
and range
values for each component.
- The
vars
method returns the parameter dictionary for both sill
and range
using the ppp_list
function.
- The
QuadStack
kernel is useful for modeling processes that exhibit multiple levels of variability
or changes in smoothness at different scales with a quadratic structure.
Source code in src/geostat/kernel.py
| class QuadStack(Kernel):
"""
QuadStack kernel class for Gaussian Processes (GPs).
The `QuadStack` class defines a kernel that combines multiple quadratic components to model complex
covariance structures. It allows for multiple sills and ranges, providing flexibility in capturing
covariance that varies across different scales.
Parameters:
range (list or tf.Variable):
A list or TensorFlow variable representing the length scale parameters that control how
quickly the covariance decreases with distance.
sill (list or tf.Variable):
A list or TensorFlow variable representing the variance (sill) values for each quadratic component.
scale (optional):
An optional scale parameter that can be used to modify the metric. Default is None.
metric (optional):
An optional metric used for distance calculation. Default is None.
Examples:
Creating and using a `QuadStack` kernel:
```python
from geostat.kernel import QuadStack
# Create a QuadStack kernel with multiple sills and ranges
quad_stack_kernel = QuadStack(range=[2.0, 3.0], sill=[1.0, 0.5])
locs1 = np.array([[0.0], [1.0], [2.0]])
locs2 = np.array([[0.0], [1.0], [2.0]])
covariance_matrix = quad_stack_kernel({'locs1': locs1, 'locs2': locs2, 'sill': [1.0, 0.5], 'range': [2.0, 3.0]})
```
Examples: Notes:
- The `call` method computes the covariance matrix using the `quadstack` function, which applies
multiple quadratic functions based on the provided `sill` and `range` values for each component.
- The `vars` method returns the parameter dictionary for both `sill` and `range` using the `ppp_list` function.
- The `QuadStack` kernel is useful for modeling processes that exhibit multiple levels of variability
or changes in smoothness at different scales with a quadratic structure.
"""
def __init__(self, range, sill, scale=None, metric=None):
fa = dict(sill=sill, range=range, scale=scale)
autoinputs = scale_to_metric(scale, metric)
super().__init__(fa, dict(d2=autoinputs))
def vars(self):
return ppp_list(self.fa['sill']) | ppp_list(self.fa['range'])
def call(self, e):
if isinstance(e['sill'], (tuple, list)):
e['sill'] = tf.stack(e['sill'])
if isinstance(e['range'], (tuple, list)):
e['range'] = tf.stack(e['range'])
return quadstack(tf.sqrt(e['d2']), e['sill'], e['range'])
|