pysiglib.idx_to_word#
Added in version v1.1.0.
- idx_to_word(idx, alphabet_size)[source]#
Given a flattened index
\[\sum_{i=0}^n (w_i + 1) d^i,\]returns the corresponding word \((w_0, w_1, \ldots, w_n)\).
- Parameters:
idx (int) – Flattened index
alphabet_size (int) – Size of the alphabet
- Returns:
Word corresponding to flattened index
- 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) # Get coefficient at index idx = 4 coef_idx = sig[idx] # Convert index to word and get coefficient at word word = pysiglib.idx_to_word(idx, dimension) coef_word = pysiglib.extract_sig_coef(word, sig, dimension, degree) # Both methods give the same coefficient print("Idx: ", idx, " Coefficient: ", coef_idx) print("Word: ", word, " Coefficient: ", coef_word)
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}
}