pysiglib.idx_to_word

pysiglib.idx_to_word#

Added in version v1.1.0.

idx_to_word(idx, alphabet_size, *, scalar_term=False)[source]#

Inverse of word_to_idx(). Given a flat index into a truncated signature, returns the corresponding word.

With scalar_term=True, index 0 maps to the empty word \(()\). With scalar_term=False (default), index 0 maps to the single-letter word (0,) and the empty word is unreachable.

Parameters:
  • idx (int) – Flat index

  • alphabet_size (int) – Size of the alphabet

  • scalar_term (bool) – Whether the source signature includes the leading scalar 1. Must match the format of the sig the index was taken from. Default False.

Returns:

Word at idx

Return type:

tuple[int, …]

Example:#

import torch
import pysiglib

length, dimension, degree = 100, 2, 3
x = torch.rand(size=(length, dimension))
sig = pysiglib.sig(x, degree)  # scalar_term=False by default

word = pysiglib.idx_to_word(4, dimension)
print(word, sig[4])

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