pysiglib.extract_sig_coef

pysiglib.extract_sig_coef#

Added in version v1.1.0.

extract_sig_coef(sig, words, dimension, *, time_aug=False, lead_lag=False, scalar_term=False)[source]#

Extracts signature coefficients from a signature or batch of signatures.

Parameters:
  • sig (numpy.ndarray | torch.tensor) – The signature or batch of signatures, of shape (..., sig_length).

  • words (tuple[int, ...] | list[tuple[int, ...]]]) – Word or list of words at which to extract coefficients.

  • dimension (int) – Dimension of the underlying path(s).

  • time_aug (bool) – Whether the signatures were computed with time_aug=True.

  • lead_lag (bool) – Whether the signatures were computed with lead_lag=True.

  • scalar_term (bool) – Whether sig includes the leading scalar 1 at index 0. Must match the format used to compute sig. Default False (matches the v3 default of pysiglib.sig()).

Returns:

Signature coefficients of shape (..., num_words), matching the leading batch dimensions of sig.

Return type:

numpy.ndarray | torch.tensor

Example:#

import torch
import pysiglib

path = torch.rand((10, 100, 5))
sigs = pysiglib.sig(path, degree=4)
words = [(0,), (1, 0), (1, 2, 3)]
coefs = pysiglib.extract_sig_coef(sigs, words, dimension=5)
print(coefs)
# Extract coefficients from signatures computed with time_aug and lead_lag
import torch
import pysiglib

path = torch.rand((10, 100, 5))
sigs = pysiglib.sig(path, degree=4, time_aug=True, lead_lag=True)

# With lead_lag the dimension doubles (10), and time_aug adds one (11).
# Words now index into the augmented dimension.
words = [(6,), (10, 9)]
coefs = pysiglib.extract_sig_coef(
    sigs, words, dimension=5, time_aug=True, lead_lag=True
)
print(coefs)

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}
}