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)[source]#

Extracts signature coefficients from a signature or batch of signatures.

Parameters:
  • sig (numpy.ndarray | torch.tensor) – The signature or batch of signatures, given as a numpy.ndarray or torch.tensor. For a single signature, this must be of shape sig_length. For a batch of paths, this must be of shape (batch_size, 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.

Returns:

Signature coefficients of shape num_words or batch of signature coefficients of shape (batch_size, num_words).

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