kernels

import "github.com/umbralcalc/stochadex/pkg/kernels"

Package kernels provides integration kernels for time-weighted aggregation and state-distance weighting in stochadex simulations. These kernels define how historical data points are weighted when computing aggregated statistics over time or when measuring similarity between states.

Key Features:

Mathematical Background: Kernels define weighting functions K(t, s) that determine how much influence a data point at time s has on the aggregated value at time t. Common patterns:

Usage Patterns:

Index

type BinnedIntegrationKernel

BinnedIntegrationKernel outputs piecewise-constant weights in time.

Usage hints:

type BinnedIntegrationKernel struct {
    // contains filtered or unexported fields
}

func (*BinnedIntegrationKernel) Configure

func (b *BinnedIntegrationKernel) Configure(partitionIndex int, settings *simulator.Settings)

func (*BinnedIntegrationKernel) Evaluate

func (b *BinnedIntegrationKernel) Evaluate(currentState []float64, pastState []float64, currentTime float64, pastTime float64) float64

func (*BinnedIntegrationKernel) SetParams

func (b *BinnedIntegrationKernel) SetParams(params *simulator.Params)

type ConstantIntegrationKernel

ConstantIntegrationKernel returns 1.0 for every sample.

Usage hints:

type ConstantIntegrationKernel struct{}

func (*ConstantIntegrationKernel) Configure

func (c *ConstantIntegrationKernel) Configure(partitionIndex int, settings *simulator.Settings)

func (*ConstantIntegrationKernel) Evaluate

func (c *ConstantIntegrationKernel) Evaluate(currentState []float64, pastState []float64, currentTime float64, pastTime float64) float64

func (*ConstantIntegrationKernel) SetParams

func (c *ConstantIntegrationKernel) SetParams(params *simulator.Params)

type ExponentialIntegrationKernel

ExponentialIntegrationKernel applies exponential decay over time.

Usage hints:

type ExponentialIntegrationKernel struct {
    // contains filtered or unexported fields
}

func (*ExponentialIntegrationKernel) Configure

func (e *ExponentialIntegrationKernel) Configure(partitionIndex int, settings *simulator.Settings)

func (*ExponentialIntegrationKernel) Evaluate

func (e *ExponentialIntegrationKernel) Evaluate(currentState []float64, pastState []float64, currentTime float64, pastTime float64) float64

func (*ExponentialIntegrationKernel) SetParams

func (e *ExponentialIntegrationKernel) SetParams(params *simulator.Params)

type GaussianStateIntegrationKernel

GaussianStateIntegrationKernel implements a Gaussian state-distance kernel for weighting historical samples based on their distance from the current state.

This kernel computes weights using a multivariate Gaussian distribution, where the weight decreases exponentially with the Mahalanobis distance between the current and historical states. It’s particularly useful for state-space aggregation and similarity-based weighting.

Mathematical Background: The Gaussian kernel computes weights using the multivariate Gaussian density:

w(x_current, x_past) = exp(-0.5 * (x_current - x_past)^T * Σ^{-1} * (x_current - x_past)) / sqrt(det(Σ))

where Σ is the covariance matrix defining the shape and scale of the weighting.

Key Properties:

Applications:

Configuration:

Example:

// Configure kernel for 2D state space with covariance matrix
// Σ = [[1.0, 0.5], [0.5, 1.0]] (correlated dimensions)
covariance := []float64{1.0, 0.5, 0.5, 1.0} // row-major flattened
params.Set("covariance_matrix", covariance)

kernel := &GaussianStateIntegrationKernel{}
kernel.Configure(0, settings)
kernel.SetParams(params)

// Weight for similar states will be high, dissimilar states low
weight := kernel.Evaluate(currentState, pastState, currentTime, pastTime)

Performance:

Error Handling:

type GaussianStateIntegrationKernel struct {
    // contains filtered or unexported fields
}

func (*GaussianStateIntegrationKernel) Configure

func (g *GaussianStateIntegrationKernel) Configure(partitionIndex int, settings *simulator.Settings)

func (*GaussianStateIntegrationKernel) Evaluate

func (g *GaussianStateIntegrationKernel) Evaluate(currentState []float64, pastState []float64, currentTime float64, pastTime float64) float64

func (*GaussianStateIntegrationKernel) SetParams

func (g *GaussianStateIntegrationKernel) SetParams(params *simulator.Params)

type InstantaneousIntegrationKernel

InstantaneousIntegrationKernel returns 1.0 for the most recent sample and 0.0 otherwise.

Usage hints:

type InstantaneousIntegrationKernel struct{}

func (*InstantaneousIntegrationKernel) Configure

func (i *InstantaneousIntegrationKernel) Configure(partitionIndex int, settings *simulator.Settings)

func (*InstantaneousIntegrationKernel) Evaluate

func (i *InstantaneousIntegrationKernel) Evaluate(currentState []float64, pastState []float64, currentTime float64, pastTime float64) float64

func (*InstantaneousIntegrationKernel) SetParams

func (i *InstantaneousIntegrationKernel) SetParams(params *simulator.Params)

type IntegrationKernel

IntegrationKernel defines the interface for time/state weighting kernels used when aggregating over historical data in simulations.

Integration kernels provide a standardized way to weight historical data points when computing aggregated statistics. They enable flexible temporal and spatial weighting schemes that can be customized for specific aggregation needs.

Mathematical Concept: Integration kernels define weighting functions w(current, past) that determine how much influence a historical data point has on the current aggregation. Common patterns include:

Interface Methods:

Weight Properties:

Common Kernel Types:

Example Usage:

kernel := &ExponentialIntegrationKernel{}
kernel.Configure(0, settings)
kernel.SetParams(params) // params contains decay rate λ

// Evaluate weight for a sample from 1.0 time units ago
weight := kernel.Evaluate(currentState, pastState, 5.0, 4.0)
// weight = exp(-λ * 1.0)

Performance Considerations:

Related Types:

type IntegrationKernel interface {
    Configure(partitionIndex int, settings *simulator.Settings)
    SetParams(params *simulator.Params)
    Evaluate(
        currentState []float64,
        pastState []float64,
        currentTime float64,
        pastTime float64,
    ) float64
}

type PeriodicIntegrationKernel

PeriodicIntegrationKernel applies periodic (circular) time weighting.

Usage hints:

type PeriodicIntegrationKernel struct {
    // contains filtered or unexported fields
}

func (*PeriodicIntegrationKernel) Configure

func (p *PeriodicIntegrationKernel) Configure(partitionIndex int, settings *simulator.Settings)

func (*PeriodicIntegrationKernel) Evaluate

func (p *PeriodicIntegrationKernel) Evaluate(currentState []float64, pastState []float64, currentTime float64, pastTime float64) float64

func (*PeriodicIntegrationKernel) SetParams

func (p *PeriodicIntegrationKernel) SetParams(params *simulator.Params)

type ProductIntegrationKernel

ProductIntegrationKernel multiplies two kernels to form a composite weight.

Usage hints:

type ProductIntegrationKernel struct {
    KernelA IntegrationKernel
    KernelB IntegrationKernel
}

func (*ProductIntegrationKernel) Configure

func (p *ProductIntegrationKernel) Configure(partitionIndex int, settings *simulator.Settings)

func (*ProductIntegrationKernel) Evaluate

func (p *ProductIntegrationKernel) Evaluate(currentState []float64, pastState []float64, currentTime float64, pastTime float64) float64

func (*ProductIntegrationKernel) SetParams

func (p *ProductIntegrationKernel) SetParams(params *simulator.Params)

type TDistributionStateIntegrationKernel

TDistributionStateIntegrationKernel applies a multivariate t kernel using an input scale matrix and degrees of freedom.

Usage hints:

type TDistributionStateIntegrationKernel struct {
    // contains filtered or unexported fields
}

func (*TDistributionStateIntegrationKernel) Configure

func (t *TDistributionStateIntegrationKernel) Configure(partitionIndex int, settings *simulator.Settings)

func (*TDistributionStateIntegrationKernel) Evaluate

func (t *TDistributionStateIntegrationKernel) Evaluate(currentState []float64, pastState []float64, currentTime float64, pastTime float64) float64

func (*TDistributionStateIntegrationKernel) SetParams

func (t *TDistributionStateIntegrationKernel) SetParams(params *simulator.Params)

Generated by gomarkdoc