pysiglib.signature#
- signature(path, degree, time_aug=False, lead_lag=False, end_time=1.0, horner=True, n_jobs=1)[source]#
Computes the truncated signature of single path or a batch of paths. For a single path \(x\), the signature is given by
\[S(x)_{[s,t]} := \left( 1, S(x)^{(1)}_{[s,t]}, \ldots, S(x)^{(N)}_{[s,t]}\right) \in T((\mathbb{R}^d)),\]\[S(x)^{(k)}_{[s,t]} := \int_{s < t_1 < \cdots < t_k < t} dx_{t_1} \otimes dx_{t_2} \otimes \cdots \otimes dx_{t_k} \in \left(\mathbb{R}^d\right)^{\otimes k}.\]- Parameters:
path (numpy.ndarray | torch.tensor) – The 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).degree (int) – The truncation level of the signature, \(N\).
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 \(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\).
horner (bool) – If True, will use Horner’s algorithm for polynomial multiplication.
n_jobs (int) – 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.
- Returns:
Truncated signature, or a batch of truncated signatures.
- Return type:
numpy.ndarray | torch.tensor
Note
Ideally, any array passed to
pysiglib.signatureshould be both contiguous and own its data. If this is not the case,pysiglib.signaturewill internally create a contiguous copy, which may be inefficient.
Citation#
If you found this library useful in your research, please consider citing the paper:
@article{shmelev2025pysiglib,
title={pySigLib-Fast Signature-Based Computations on CPU and GPU},
author={Shmelev, Daniil and Salvi, Cristopher},
journal={arXiv preprint arXiv:2509.10613},
year={2025}
}