pysiglib.sig_combine#
- sig_combine(sig1, sig2, dimension, degree, n_jobs=1)[source]#
Combines two truncated signatures of the same degree and dimension into one signature. In particular, let \(x_1, x_2\) be two paths such that the first point of \(x_2\) is the last point of \(x_1\). Let \(S(x_1), S(x_2)\) be the truncated signatures of \(x_1, x_2\) respectively. Then calling this function on \(S(x_1), S(x_2)\) returns the truncated signature of the concatenated path,
\[S(x_1 * x_2) = S(x_1) \otimes S(x_2),\]where \(x_1 * x_2\) is the concatenation of the two paths \(x_1, x_2\).
- Parameters:
sig1 (numpy.ndarray | torch.tensor) – The first truncated signature
sig2 (numpy.ndarray | torch.tensor) – The second truncated signature. Must have the same degree and dimension as the first.
dimension (int) – Dimension of the underlying space, \(d\).
degree (int) – Truncation level of the signatures, \(N\)
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:
Combined signature, \(S(x_1 * x_2)\)
- Return type:
numpy.ndarray | torch.tensor
Note
Parallelising the computation by setting
n_jobs != 1can be beneficial when the workload is large. However, if the workload is too small, it may be faster to set this to1and run the computation serially, due to parallelisation overhead.Note
Ideally, any array passed to
pysiglib.sig_combineshould be both contiguous and own its data. If this is not the case,pysiglib.sig_combinewill internally create a contiguous copy, which may be inefficient.Example usage:
import pysiglib batch_size = 32 length = 100 dimension = 5 degree = 3 X1 = np.random.uniform(size=(batch_size, length, dimension)) X2 = np.random.uniform(size=(batch_size, length, dimension)) X_concat = np.concatenate((X1, X2), axis=1) X2 = np.concatenate((X1[:, [-1], :], X2), axis=1) # Make sure first pt of X2 is last pt of X1 sig1 = pysiglib.signature(X1, degree) sig2 = pysiglib.signature(X2, degree) # The tensor product... sig_mult = pysiglib.sig_combine(sig1, sig2, dimension, degree) # ... is the same as the signature of the concatenated path: sig = pysiglib.signature(X_concat, degree)
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}
}