Skip to content

add the variational Bayes Factor Analysis for noise learning - #2

Merged
orabe merged 1 commit into
mainfrom
vbfa_variational_bayes_factor_analysis
May 8, 2025
Merged

orabe merged 1 commit into
mainfrom
vbfa_variational_bayes_factor_analysis

Conversation

@AliHashemi-ai

Copy link
Copy Markdown
Contributor

@orabe @IsmailHuseynov @stefanhaufe

Add Variational Bayes Factor Analysis (VBFA) module

Description

Here I add the Python implementation of the Variational Bayes Factor Analysis (VBFA) algorithm (Attias, 2005) for regularized covariance estimation. VBFA class with E-step/M-step updates, likelihood tracking, and optional convergence plotting. I put a little bit of mathematical background to make the method more understandable.

Key Changes

  • New file: calibrain/vbfa.py
  • VBFA class with:
    • _svd_sqrt initialization from data covariance
    • E-step (_compute_gamma, posterior expectations)
    • M-step (_update_b, _update_bet, _update_lam)
    • Likelihood computation and optional plots of free energy, (1/β), (1/λ)

Algorithm Overview

  1. Init:
    • (R_{yy} = Y Y^\top / N_t)
    • (B_0 = U,\sqrt{D}) (top-(n_l) eigenpairs)
    • (\lambda_i = 1 / \mathrm{diag}(R_{yy}),; β_j = 1)
  2. EM iterations:
    • E-step:
      (\Gamma = B^\top\mathrm{diag}(\lambda)B + I + N_kR_{BB}),
      (\bar U = \Gamma^{-1}B^\top\mathrm{diag}(\lambda)Y),
      (R_{uu} = \bar U\bar U^\top + N_t\Gamma^{-1}.)
    • M-step: update (β), (B), and (\lambda) via closed-form updates.
  3. Output:
    • sig = B Bᵀ + diag(1/λ)
    • weight = B Γ⁻¹ Bᵀ diag(λ)
    • yc and cy for reconstructed data and model covariance

Testing & Validation

  • Sanity check under __main__ using random data
  • Verified monotonic likelihood improvement and correct covariance reconstruction

@orabe
orabe merged commit 1719f08 into main May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants