pysiglib.log_sig#
Added in version v1.0.0.
- log_sig(path, degree, time_aug=False, lead_lag=False, end_time=1.0, method=1, n_jobs=1)[source]#
Computes the log signature using the specified method. For details, see the page Computing Log Signatures.
- Parameters:
path (numpy.ndarray | torch.tensor) – The underlying path or batch of paths, given as a numpy.ndarray or torch.tensor. For a single path, this must be of shape
(length, dimension). For a batch of paths, this must be of shape(batch_size, length, dimension).degree (int) – Truncation degree of the (log) signature(s).
time_aug (bool) – If set to True, will compute the log signature of the time-augmented path, \(\hat{x}_t := (t, x_t)\), defined as the original path with an extra channel set to time, \(t\). This channel spans \([0, t_L]\), where \(t_L\) is given by the parameter
end_time.lead_lag (bool) – If set to True, will compute the log signature of the path after applying the lead-lag transformation.
end_time (float) – End time for time-augmentation, \(t_L\).
method (int) – Method to use for the log signature computation (0, 1 or 2).
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.
- 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_log_sig = pysiglib.log_sig(X, 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}
}