I've been working with multilinear machine learning models recently, and trying to construct the correlation between items, given that you let other items vary.
In other words, given a multilinear function $f$, I want to calculate the correlation between $f(a, X, Y, \ldots)$ and $f(b, X, Y, \ldots)$ where $X$ and $Y$ are discrete distributions of known values, for several values of $b$ (I want to find the most correlated items $b$, given an $a$ and the function $f$).
To do this efficiently, I construct a covariance matrix over the parts of the function that varies.
For example, if $f(a, x)$ is the dot product between vectors a and x, it boils down to computing the covariance matrix of $X$, and if $f(a, x ,y)$ is the sum of the elementwise products of vectors $a$, $x$, and $y$, the corresponding covariance matrix can be computed from the individual moments of $X$ and $Y$.
So far I've been doing this "by hand" on a function to function basis, and now I'm wondering if there's a general way to go from multilinear function formulation (in, for example, einstein notation) to covariance computation.