Skip to content

RampStack

src.geostat.kernel.RampStack

Bases: Kernel

RampStack kernel class for Gaussian Processes (GPs).

The RampStack class defines a kernel that extends the standard Ramp kernel by allowing for multiple sills and ranges, effectively creating a "stacked" ramp function. This kernel can capture more complex covariance structures with multiple levels of decay.

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 ramp 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 RampStack kernel:

from geostat.kernel import RampStack

# Create a RampStack kernel with multiple sills and ranges
ramp_stack_kernel = RampStack(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 = ramp_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 rampstack function, which applies multiple ramp 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 RampStack kernel is useful for modeling complex processes that exhibit multiple levels of variability or changes in smoothness at different scales.
Source code in src/geostat/kernel.py
class RampStack(Kernel):
    """
    RampStack kernel class for Gaussian Processes (GPs).

    The `RampStack` class defines a kernel that extends the standard `Ramp` kernel by allowing for multiple 
    sills and ranges, effectively creating a "stacked" ramp function. This kernel can capture more complex 
    covariance structures with multiple levels of decay.

    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 ramp 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 `RampStack` kernel:

        ```python
        from geostat.kernel import RampStack

        # Create a RampStack kernel with multiple sills and ranges
        ramp_stack_kernel = RampStack(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 = ramp_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 `rampstack` function, which applies 
            multiple ramp 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 `RampStack` kernel is useful for modeling complex processes that exhibit multiple levels of variability 
            or changes in smoothness at different scales.
    """

    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 rampstack(tf.sqrt(e['d2']), e['sill'], e['range'])