Expectation of a product of quadratic forms — the explicit expression, live

Kan & Pan give an explicit formula for 𝔼[∏i z′Aiz] with z ∼ N(μ, Σ), Σ only positive semidefinite, in which no term is repeated and every coefficient is a power of two. Every term is a product of two kinds of scalars, θν = μ′Aν₁ΣAν₂Σ⋯ΣAνpμ and τν = tr(Aν₁ΣAν₂Σ⋯AνpΣ), indexed by canonical words: θ-words up to reversal, τ-words up to rotation and reversal (bracelets). Draw each τ-word as a cycle through its labels and each θ-word as a path capped by μ at both ends: every term of the expansion is then a cover of the labels {1,…,k} by disjoint cycles and paths, and every cover appears exactly once.

The same machinery gives Hermitian forms in complex normal vectors (the real part is taken term by term), products with repeated forms 𝔼[∏(z′Aiz)si], and the Wishart product moments 𝔼[∏ tr(WAi)]. Use the switch below to move between the quadratic-form and Wishart halves and between the real and complex cases.

Part 1From set partitions to distinct terms

k mean view

Part 2Generate it yourself

presets:
Idle. Enter a power vector and generate.

Evaluate numerically — and check it three independent ways

show the matrices used

Part 3How many terms? — the price of each route

Every count on this chart is computed live on this page from the closed forms in the paper (and, for the two “ours” series up to the sizes Part 2 can reach, confirmed by actually enumerating the terms). Hover to read values.