Skip to content
BIASED
Back to topic

Optional

FID from 1D moments of two Gaussians

Analytic FID=(Δμ)²+(Δσ)² and an empirical estimate. Self-check in the notebook.

Version
v1
Minutes
~15
Evidence
Self-check in the notebook

Until platform auto-check exists, compare cell output with the expected numbers in the notebook. This is not a debt and does not affect mastery.

Download .ipynb

Download the notebook and run it locally. Its environment requirements are listed inside.

Notebook contents

Readable on your phone. The code below has not been executed in the browser; download the notebook to run it.

GM · FID на 1D моментах / FID from 1D moments

Activity version: 1 · Seed: 0 · Данные: две гауссианы в R\mathbb R.

Тема FID: для гауссиан

FID=∥μr−μg∥2+Tr(Σr+Σg−2(ΣrΣg)1/2).\mathrm{FID}=\|\mu_r-\mu_g\|^2 + \mathrm{Tr}(\Sigma_r+\Sigma_g-2(\Sigma_r\Sigma_g)^{1/2}).

В 1D это (μr−μg)2+(σr−σg)2(\mu_r-\mu_g)^2 + (\sigma_r-\sigma_g)^2.

Ожидаемые числа
(μr,σr)(\mu_r,\sigma_r) vs (μg,σg)(\mu_g,\sigma_g) FID Tolerance
(0,1)(0,1) vs (0,1)(0,1) 0 exact
(0,1)(0,1) vs (1,1)(1,1) 1 exact
(0,1)(0,1) vs (0,2)(0,2) 1 exact
empirical FID seed 0, n=20000 ≈ analytic abs ≤ 0.05
Самопроверка в ноутбуке

Не влияет на mastery.

import numpy as np
 
def fid_1d(mu_r, sig_r, mu_g, sig_g):
    return (mu_r - mu_g) ** 2 + (sig_r - sig_g) ** 2
 
assert fid_1d(0, 1, 0, 1) == 0
assert fid_1d(0, 1, 1, 1) == 1
assert fid_1d(0, 1, 0, 2) == 1
 
rng = np.random.default_rng(0)
r = rng.normal(0, 1, size=20000)
g = rng.normal(1, 1, size=20000)
mu_r, mu_g = r.mean(), g.mean()
sig_r, sig_g = r.std(ddof=0), g.std(ddof=0)
emp = fid_1d(mu_r, sig_r, mu_g, sig_g)
print("empirical FID", emp, "analytic", 1.0)
assert abs(emp - 1.0) < 0.05
print("OK: FID moments toy")
 
Самопроверка в ноутбуке
  • три аналитических случая
  • эмпирика ≈ 1 при сдвиге среднего