Shuffle Tensors

What are shuffle tensors

Shuffle tensors are one way of representing the linear functionals on free tensors. The shuffle product corresponds to pointwise multiplication of the continuous functions on paths via the signature correspondence. For more information on shuffle tensors, see Reutenauer [Reu93].

How do shuffle tensors fit into RoughPy

Shuffle tensors are useful because they represent functions on paths via the signature.

How to work with shuffle tensors

You can create shuffle tensors in the following way. In this example we will use polynomial coefficients to demonstrate how shuffles behave.

>>> from roughpy import ShuffleTensor, Monomial

>>> shuffle_tensor1 = ShuffleTensor([1 * Monomial(f"x{i}") for i in range(7)], width=2,
                depth=2, dtype=roughpy.RationalPoly)
>>> print(f"{shuffle_tensor1=!s}")
shuffle_tensor1={ { 1(x0) }() { 1(x1) }(1) { 1(x2) }(2) { 1(x3) }(1,1) { 1(x4) }(1,2) { 1(x5) }(2,1) { 1(x6) }(2,2) }

>>> shuffle_tensor2 = ShuffleTensor([1 * Monomial(f"y{i}") for i in range(7)], width=2,
                depth=2, dtype=roughpy.RationalPoly)
>>> print(f"{shuffle_tensor2=!s}")
shuffle_tensor2={ { 1(y0) }() { 1(y1) }(1) { 1(y2) }(2) { 1(y3) }(1,1) { 1(y4) }(1,2) { 1(y5) }(2,1) { 1(y6) }(2,2) }

We can shuffle these together

>>> result = shuffle_tensor1*shuffle_tensor2
>>> print(f"{result=!s}")
result={ { 1(x0 y0) }() { 1(x0 y1) 1(x1 y0) }(1) { 1(x0 y2) 1(x2 y0) }(2) { 1(x0 y3) 2(x1 y1) 1(x3 y0) }(1,1) { 1(x0 y4) 1(x1 y2) 1(x2 y1) 1(x4 y0) }(1,2) { 1(x0 y5) 1(x1 y2) 1(x2 y1) 1(x5 y0) }(2,1) { 1(x0 y6) 2(x2 y2) 1(x6 y0) }(2,2) }

Literature references


N. Bourbaki. Algebra I: Chapters 1-3. Springer Science & Business Media, August 1998. ISBN 978-3-540-64243-5. Google-Books-ID: STS9aZ6F204C.


Nicolas Bourbaki. Lie Groups and Lie Algebras: Chapters 1-3. Springer Science & Business Media, 1989. ISBN 978-3-540-64242-8. Google-Books-ID: brSYF_rB2ZcC.


Patrick Kidger, James Morrill, James Foster, and Terry Lyons. Neural Controlled Differential Equations for Irregular Time Series. November 2020. arXiv:2005.08926 [cs, stat]. URL: (visited on 2023-12-08), doi:10.48550/arXiv.2005.08926.


Terry Lyons and Andrew D. McLeod. Signature Methods in Machine Learning. January 2024. arXiv:2206.14674 [cs, math, stat]. URL: (visited on 2024-02-14).


Terry J. Lyons, Michael J. Caruana, and Thierry Lévy. Differential Equations Driven by Rough Paths: Ecole d’Eté de Probabilités de Saint-Flour XXXIV-2004. Springer, April 2007. ISBN 978-3-540-71285-5. Google-Books-ID: hOm5BQAAQBAJ.


Christophe Reutenauer. Free Lie Algebras. Clarendon Press, 1993. ISBN 978-0-19-853679-6. Google-Books-ID: cBvvAAAAMAAJ.