For starters, let's have an ensemble of $n$ random variables $\mathbf{x}, \mathbf{y}$, $$ \begin{align} \mathbf{x} &= (x_1, \cdots, x_n) \\ \mathbf{y} &= (y_1, \cdots, y_n) \end{align} $$ and we want to check for independence of $\mathbf{x}$ and $\mathbf{y}$. It's said that the variables are independent if all mean values $\langle f(x) g(y) \rangle$ are equal to $\langle f(x) \rangle \langle g (x) \rangle$.
What would be a good basis of functions such that if all $$ \langle f_i (x) g_j (y) \rangle = \langle f_i (x) \rangle \langle g_j (x) \rangle $$ then we can say $\mathbf{x}, \mathbf{y}$ are independent? What about just powers $$ \begin{align} \langle x^a y^b \rangle &= \langle x^a \rangle \langle y^b \rangle \\ \frac{1}{n} \sum_{i = 1}^n x_i^a y_i^b &= \frac{1}{n^2} \left( \sum_{i = 1}^n x_i^a \right) \left( \sum_{i = 1}^n y_i^b \right) \end{align} $$ for all integers $a, b$? Can we find a dataset in which 2 variables are correlated and yet all these powers show no correlation? What would be a universal set of functions to use here that rules out dependence for sure?
Since we are dealing with an actual ensemble, the answer might be given probabilistically; given the values of some correlation coefficients $$ \frac{\langle f(x) g(y) \rangle - \langle f(x) \rangle \langle g(y) \rangle}{\sqrt{\langle f^2 (x) \rangle - \langle f(x) \rangle^2} \sqrt{\langle g^2 (y) \rangle - \langle g(y) \rangle^2}}, $$ for various functions $f, y$, what is the probability that $\mathbf{x}, \mathbf{y}$ are (in)dependent?
Would this approach be generalizable to three and more random variables i.e. examining $$ \langle f(x) g(y) h(z) \rangle = \langle f(x) \rangle \langle g(y) \rangle \langle h(z) \rangle $$ and drawng some statistical conclusion about the independence of their underlying distribution?
P.S.: I am thinking that practically, a sufficiently tedious test would always conclude that the variables are dependent. For any tiny correlation between two random variables we could come up with a tailored function that enhances the correlation...