BCH Coefficients
log_signatures_pytorch.bch_coefficients.bch_coeffs(width, depth)
Coefficients for log(prod_{i=1}^width exp(e_i)) truncated to depth.
Computes the exact rational coefficients for the Baker-Campbell-Hausdorff expansion of the product of exponentials of generators, truncated to the specified depth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
Number of generators (path dimension). Must be >= 1. |
required |
depth
|
int
|
Truncation depth. Must be >= 1. |
required |
Returns:
| Type | Description |
|---|---|
CoeffMap
|
Dictionary mapping tensor-algebra words (tuples of generator indices) to rational coefficients (Fraction objects) in the series expansion. Words are tuples of integers from 1 to width, representing the generators in order. |
Examples:
>>> from log_signatures_pytorch.bch_coefficients import bch_coeffs
>>> from fractions import Fraction
>>>
>>> # BCH coefficients for width=2, depth=2
>>> coeffs = bch_coeffs(2, 2)
>>> # Check some expected coefficients
>>> coeffs[(1,)] == Fraction(1, 1)
True
>>> coeffs[(2,)] == Fraction(1, 1)
True
>>> # The bracket [1, 2] has coefficient 1/2, split across (1, 2) and (2, 1)
>>> coeffs.get((1, 2), 0) == Fraction(1, 2)
True
>>> coeffs.get((2, 1), 0) == Fraction(-1, 2)
True
>>> coeffs.get((1, 2), 0) - coeffs.get((2, 1), 0) == Fraction(1, 1)
True
>>>
>>> # BCH coefficients for width=3, depth=2
>>> coeffs = bch_coeffs(3, 2)
>>> # Three degree-1 generators
>>> len([w for w in coeffs.keys() if len(w) == 1])
3