pysiglib.sig_to_log_sig

pysiglib.sig_to_log_sig#

Added in version v1.0.0.

sig_to_log_sig(sig, dimension, degree, *, time_aug=False, lead_lag=False, method=1, n_jobs=1)[source]#

Computes the log signature from the signature, using the specified method. For details, see the page Computing Log 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).

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

  • degree (int) – Truncation degree of the (log) signature(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.

  • method (int) – Method to use for the log signature computation (0, 1 or 2). Method 3 is not supported here; use pysiglib.log_sig with method=3 instead.

  • 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:

Log signature or a batch of log signatures. For method 0 (expanded), the output matches the scalar-term format of the input sig. Methods 1 and 2 produce log-sig-shaped output (no scalar term).

Return type:

numpy.ndarray | torch.tensor

Example usage:#

import torch
import pysiglib

pysiglib.prepare_log_sig(5, 3, lead_lag=True, method=2)

X = torch.rand((32,100,5))
X_sig = pysiglib.sig(X, 3, lead_lag=True)
X_log_sig = pysiglib.sig_to_log_sig(X_sig, 5, 3, lead_lag=True, method=2)

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