pysiglib.sig_kernel#
- sig_kernel(path1, path2, dyadic_order, time_aug=False, lead_lag=False, end_time=1.0, n_jobs=1, return_grid=False)[source]#
Computes a single signature kernel or a batch of signature kernels. The signature kernel of two \(d\)-dimensional paths \(x,y\) is defined as
\[k_{x,y}(s,t) := \left< S(x)_{[0,s]}, S(y)_{[0, t]} \right>_{T((\mathbb{R}^d))}\]where the inner product is defined as
\[\left< A, B \right> := \sum_{k=0}^{\infty} \left< A_k, B_k \right>_{\left(\mathbb{R}^d\right)^{\otimes k}}\]\[\left< u, v \right>_{\left(\mathbb{R}^d\right)^{\otimes k}} := \prod_{i=1}^k \left< u_i, v_i \right>_{\mathbb{R}^d}\]- Parameters:
path1 (numpy.ndarray | torch.tensor) – The first underlying path or batch of paths, given as a numpy.ndarray or torch.tensor. For a single path, this must be of shape (length, dimension). For a batch of paths, this must be of shape (batch size, length, dimension).
path2 (numpy.ndarray | torch.tensor) – The second underlying path or batch of paths, given as a numpy.ndarray or torch.tensor. For a single path, this must be of shape (length, dimension). For a batch of paths, this must be of shape (batch size, length, dimension).
dyadic_order (int | tuple) – If set to a positive integer \(\lambda\), will refine the PDE grid by a factor of \(2^\lambda\).
time_aug (bool) – If set to True, will compute the signature of the time-augmented path, \(\hat{x}_t := (t, x_t)\), defined as the original path with an extra channel set to time, \(t\). This channel spans \([0, t_L]\), where :math`t_L` is given by the parameter
end_time.lead_lag (bool) – If set to True, will compute the signature of the path after applying the lead-lag transformation.
end_time (float) – End time for time-augmentation, \(t_L\).
n_jobs (int) – (Only applicable to CPU computation) Number of threads to run in parallel. If n_jobs = 1, the computation is run serially. If set to -1, all available threads are used. For n_jobs below -1, (max_threads + 1 + n_jobs) threads are used. For example if n_jobs = -2, all threads but one are used.
return_grid (bool) – If
True, returns the entire PDE grid.
- Returns:
Single signature kernel or batch of signature kernels
- Return type:
numpy.ndarray | torch.tensor
Note
Ideally, any array passed to
pysiglib.sig_kernelshould be both contiguous and own its data. If this is not the case,pysiglib.sig_kernelwill internally create a contiguous copy, which may be inefficient.