pysiglib.linear_sig#
Added in version v3.0.0.
- linear_sig(displacement, dimension, degree, *, scalar_term=False, n_jobs=1)[source]#
Computes the truncated signature of a single linear segment defined by a displacement vector. Given a displacement vector \(v \in \mathbb{R}^d\), this computes the signature of the linear path from \(0\) to \(v\),
\[S(v) = \left(1, v, \frac{v^{\otimes 2}}{2!}, \ldots, \frac{v^{\otimes N}}{N!}\right).\]- Parameters:
displacement (numpy.ndarray | torch.tensor) – The displacement vector or batch of displacement vectors. For a single displacement, this must be of shape
(dimension,). For a batch, this must be of shape(batch_size, dimension).dimension (int) – Dimension of the underlying space, \(d\).
degree (int) – Truncation level of the signature, \(N\).
scalar_term (bool) – If True, the output includes the leading constant 1 at index 0 (the empty-word term). If False (default), this leading element is stripped from the output.
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 of the linear segment, or a batch of truncated signatures.
- Return type:
numpy.ndarray | torch.tensor
Example:#
import pysiglib import numpy as np dimension = 5 degree = 3 displacement = np.random.uniform(size=(dimension,)) lsig = pysiglib.linear_sig(displacement, dimension, degree) # Batch version batch_size = 32 displacements = np.random.uniform(size=(batch_size, dimension)) lsigs = pysiglib.linear_sig(displacements, dimension, degree, n_jobs=-1)
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}
}