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 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 · Данные: две гауссианы в .
Тема FID: для гауссиан
В 1D это .
Ожидаемые числа
| vs | FID | Tolerance |
|---|---|---|
| vs | 0 |
exact |
| vs | 1 |
exact |
| vs | 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 при сдвиге среднего