aseyboldt / covadapt-paper

1 stars 1 forks source link

Note issue with formula #2

Open maresb opened 18 hours ago

maresb commented 18 hours ago

The following formula image doesn't hold in general. For that you'd need matrices to be simultaneously diagonalizable.

aseyboldt commented 18 hours ago

You are right... I guess I'm lucky I never used that one for anything. The square root expression is right though:

def geomean(A, B):
    A_sqrt = linalg.sqrtm(A)
    A_isqrt = linalg.inv(A_sqrt)
    return A_sqrt @ linalg.sqrtm(A_isqrt @ linalg.inv(B) @ A_isqrt) @ A_sqrt

np.allclose(geomean(covx, covalpha), C)

This is where I compute it in nutpie: https://github.com/pymc-devs/nuts-rs/blob/main/src/low_rank_mass_matrix.rs#L409 Please don't find a mistake in there ;-)

maresb commented 18 hours ago

It turns out you can solve this.

If $A=\mathrm{Cov}[\alpha_i]$ and $B=\mathrm{Cov}[x_i]$, then

$$\Sigma = A^{-1/2} \left( A^{1/2} B A^{1/2} \right)^{1/2} A^{-1/2}$$

aseyboldt commented 18 hours ago

That was the "or some expression with lots of matrix square roots (todo)." in the paper :D Cutting corners always gets punished

maresb commented 18 hours ago

Where is geomean from?

aseyboldt commented 18 hours ago

I think it was this: https://www.lix.polytechnique.fr/~nielsen/MIGBOOKWEB/9783642302312-c2.pdf

maresb commented 17 hours ago

I mean the code for geomean. Is that copy-pasted from somewhere?

aseyboldt commented 17 hours ago

No, I just wrote the code. Same solution you just posted.