独立成分分析:分离的不只是协方差
Independent component analysis
推导白化与立方 FastICA,恢复原创有限混合,并检查一个收敛后仍然依赖的方向。
ica两个传感器,两条隐藏信号
两个传感器分别记录了两种过程的不同混合。转动散点图,让两个坐标的协方差变成零,是有用的第一步。但这不能告诉我们哪些轴对应原来的过程:许多旋转都能保持零协方差。
独立成分分析(ICA)要求更强的分离。在基本线性模型中,每个恢复出的坐标都不应携带关于其他坐标的统计信息。这是对源信号的建模假设,不能靠两条看起来分明的曲线来确认。Hyvärinen 与 Oja 的综述介绍了这一模型及其尺度、顺序歧义。
本实验有八种等概率情况。第一条源信号取 −1 或 1;第二条独立地取 −2、−1、1 或 2。传感器报告 x1 = 7 + 2*s1 + s2 和 x2 = -4 + s1 + 3*s2。算法只能看到传感器值;已知源信号留到最后检验结果。
这里用完整笛卡尔积表示一个精确的有限分布,并不是说随便测量八次就足够分离信号。这样可以把三个问题分开:白化是否成功,迭代是否停止,输出是否真正恢复了源信号?
白化消除协方差,不消除依赖
考虑方阵、无噪声模型,要求混合矩阵可逆,源信号具有有限且非零的方差。把源的均值吸收到偏移量,把尺度吸收到混合矩阵的列中,便可让中心化后的源具有单位方差:
独立源意味着最后一个等式成立,反过来却不成立。通常的可辨识性结论还要求最多只有一个高斯源。若某个子空间包含多个独立的单位高斯源,正交旋转会得到同一个高斯分布,观测就无法选出原轴。即便模型可辨识,把某条源乘以非零常数、同时将对应混合列除以这个常数,观测也不变;交换源的顺序同样不变。固定单位方差后,仍有符号和排列歧义。这些是模型本身的性质,不能靠更小的停止容差解决。ICA 综述,第 2–3 节
对非奇异协方差,选择对角元为正的 Cholesky 因子。白化先减去拟合均值,再解一个三角方程组:
未知混合现在成为正交旋转或反射。基于 PCA 的对称白化也是有效选择;不同白化方式改变的是估计剩余旋转所用的坐标系。两者都不能确立独立性。程序估计协方差时以 n 为分母,并始终沿用此约定。单位协方差在实数精确运算下成立;实现会检查它的数值近似。
若想看到协方差以外的信息,可以使用中心化标量的四阶累积量。在单位方差下,它等于超额峰度。若 u1,u2 是相互独立的标准化源,混合四阶矩可以分解,得到:
四阶矩中的交叉项是 6*a²*b²,它与方差平方中的对应项抵消。本例两条源的累积量为 −2 和 −41/25。因为两者都是负数,混合累积量的绝对值为 2*a⁴+(41/25)*b⁴,不超过 2:使用 a⁴+b⁴ ≤ (a²+b²)² = 1 即可。源轴是这个对比函数下具有局部吸引性的候选方向。这一论证依赖假定的独立源及其累积量。非高斯分布也可能具有零四阶累积量,因此峰度不是万能的独立性检验。
立方非线性的单分量 FastICA 从单位方向出发,用四阶矩更新方向。其不动点形式不需要另外选择学习率:
该更新来自单位球面上四阶累积量对比函数的驻点方程。−3*w 这一项使用了数据已白化、方向为单位向量的条件。不区分正负号的距离很重要:恢复的源与其相反数代表同一条轴。若更新为零向量,就无法归一化;程序单独报告这种情况。不动点算法,第 3.1 节
在二维空间中,已恢复源方向的垂线给出另一条轴。程序利用这一点,没有实现一般多分量的逐次提取过程。如果第一条轴找错了,取它的垂线也无法挽救分离结果。
让小型求解器如实报告停止原因
以下完整程序只需要 Python 3 和标准库。fit_ica 复制观测、完成白化、迭代一个方向,再返回拟合均值、Cholesky 因子、两条轴与累积量。transform 对新数据沿用这些拟合量,其模型参数应是未经修改的 fit_ica 返回值。
converged 只表示方向变化在 tol 内,不是源信号或最优性的证书。iteration-limit 表示预算耗尽前尚未通过此检查。预算为零时,仍拟合白化变换,并返回初始轴。degenerate-update 表示某次尝试得到零向量,保留上一条轴。iterations 计算尝试更新的次数。显示时,让第一条轴绝对值最大的坐标为正;两坐标同分时选第一个。
from math import fsum, hypot, isfinite, sqrt
def number(value):
if type(value) not in (int, float):
raise ValueError('use finite int or float coordinates')
try:
value = float(value)
except OverflowError as exc:
raise ValueError('coordinate is outside float range') from exc
if not isfinite(value):
raise ValueError('nonfinite number')
return value
def rows2(rows):
try:
result = tuple(tuple(number(v) for v in row) for row in rows)
except TypeError as exc:
raise ValueError('expected rows of two coordinates') from exc
if any(len(row) != 2 for row in result):
raise ValueError('expected rows of two coordinates')
return result
def finite(value):
if not isfinite(value):
raise ValueError('nonfinite intermediate; rescale the data')
return value
def average(values, n):
try:
return finite(fsum(values) / n)
except (OverflowError, ValueError) as exc:
raise ValueError('unstable arithmetic; rescale the data') from exc
def unit(pair):
length = hypot(*pair)
if length == 0 or not isfinite(length):
raise ValueError('direction must have a finite nonzero norm')
return tuple(v / length for v in pair)
def whiten(data):
data = rows2(data)
n = len(data)
if n < 3:
raise ValueError('at least three rows are required')
mean = tuple(average((row[j] for row in data), n) for j in range(2))
centered = tuple(tuple(finite(row[j] - mean[j]) for j in range(2))
for row in data)
a = average((x*x for x, y in centered), n)
b = average((x*y for x, y in centered), n)
c = average((y*y for x, y in centered), n)
# Absolute safeguards in the input's squared units, not regularization.
if a <= 1e-12:
raise ValueError('first covariance pivot is too small')
l00 = sqrt(a)
l10 = b / l00
pivot = finite(c - l10*l10)
if pivot <= 1e-12:
raise ValueError('second covariance pivot is too small')
l11 = sqrt(pivot)
z = tuple((x/l00, (y - l10*(x/l00))/l11) for x, y in centered)
cov = (average((u*u for u, v in z), n),
average((u*v for u, v in z), n),
average((v*v for u, v in z), n))
if max(abs(cov[0]-1), abs(cov[1]), abs(cov[2]-1)) > 1e-6:
raise ValueError('whitening lost accuracy; rescale or change method')
return mean, (l00, l10, l11), z
def transform(model, data):
# model must be a result of fit_ica; no refitting on the new rows.
rows = rows2(data)
l00, l10, l11 = model['cholesky']
result = []
for x, y in rows:
u = finite((x - model['mean'][0]) / l00)
v = finite((y - model['mean'][1] - l10*u) / l11)
result.append(tuple(finite(a*u + b*v) for a, b in model['axes']))
return tuple(result)
def fit_ica(data, initial=(1, 0), max_iter=100, tol=1e-10):
if type(max_iter) is not int or max_iter < 0:
raise ValueError('max_iter must be a nonnegative integer')
tol = number(tol)
if not 0 < tol < 1:
raise ValueError('tol must be between zero and one')
w = unit(rows2((initial,))[0])
data = rows2(data)
mean, chol, z = whiten(data)
status, iterations = 'iteration-limit', 0
n = len(z)
for iterations in range(1, max_iter + 1):
projection = tuple(w[0]*u + w[1]*v for u, v in z)
raw = tuple(average((row[j]*t*t*t for row, t in zip(z, projection)), n)
- 3*w[j] for j in range(2))
if hypot(*raw) == 0:
status = 'degenerate-update'
break
new = unit(raw)
gap = min(hypot(new[0]-w[0], new[1]-w[1]),
hypot(new[0]+w[0], new[1]+w[1]))
w = new
if gap <= tol:
status = 'converged'
break
# Choose a display sign; it carries no source meaning.
j = 0 if abs(w[0]) >= abs(w[1]) else 1
if w[j] < 0:
w = (-w[0], -w[1])
model = {'mean': mean, 'cholesky': chol,
'axes': (w, (-w[1], w[0])),
'status': status, 'iterations': iterations}
values = transform(model, data)
model['cumulants'] = tuple(
average((row[j]**4 for row in values), n)
- 3*average((row[j]**2 for row in values), n)**2
for j in range(2))
return model
def main():
sources = tuple((a, b) for a in (-1, 1) for b in (-2, -1, 1, 2))
data = tuple((7 + 2*a + b, -4 + a + 3*b) for a, b in sources)
model = fit_ica(data)
values = transform(model, data)
correlations = tuple(tuple(abs(fsum(row[j]*source[k]
for row, source in zip(values, sources))/len(data)
/ sqrt((1, 2.5)[k])) for k in range(2)) for j in range(2))
print('main:', model['status'], model['iterations'])
print('cumulants:', tuple(round(x, 6) for x in model['cumulants']))
print('absolute source correlations:',
tuple(tuple(round(v, 6) for v in row) for row in correlations))
symmetric = tuple((a, b) for a in (-1, 1) for b in (-1, 1))
bad = fit_ica(symmetric, initial=(1, 1))
rotated = transform(bad, symmetric)
cross = fsum(u*u*v*v for u, v in rotated)/4
product = (fsum(u*u for u, v in rotated)/4
* fsum(v*v for u, v in rotated)/4)
print('diagonal:', bad['status'], bad['iterations'],
tuple(round(x, 6) for x in bad['cumulants']))
print('square-product moments:', round(cross, 6), round(product, 6))
print('zero budget:', fit_ica(data, max_iter=0)['status'])
if __name__ == '__main__':
main()
输出为:
main: converged 5
cumulants: (-2.0, -1.64)
absolute source correlations: ((1.0, 0.0), (0.0, 1.0))
diagonal: converged 1 (-1.0, -1.0)
square-product moments: 0.0 1.0
zero budget: iteration-limit
第一次拟合恢复了两条标准化源,允许符号不同。与已知源的相关性验证了这一次结果;真正的盲分离应用无法取得这项信息。第二次拟合使用另一组对称源分布,从对角线出发后立即停止。它反驳了“出现停止标记就意味着分离成功”的想法。
固定为两个坐标时,n 条观测、T 次更新尝试需要 O(n*(T+1)) 次算术运算和 O(n) 个存储数值。变换 m 条新数据需要 O(1+m) 时间及输出空间。这些是浮点运算计数,不是精确实数计算的复杂度结论。输入复制、白化及累积量报告均已计入,程序不保存随迭代增长的轨迹。
不动点仍然可能混合了源信号
取两个相互独立、等概率为正负一的源 s1,s2,旋转成 u=(s1+s2)/sqrt(2) 和 v=(-s1+s2)/sqrt(2)。输出具有零均值、单位方差及零协方差。但 E[u²*v²]=0,而 E[u²]*E[v²]=1:一个输出非零时,另一个必为零,因此它们相互依赖。两者累积量都是 −1。对角线是立方迭代中恰好反转符号的不动点,这解释了上面的第二个结果。改用源轴可以得到 −2 的累积量,但方向变化检查并没有询问是否存在更好的对比函数值。
有限样本会让问题更难:估计的四阶矩会波动,还可能受异常值主导。多个起点和其他对比函数可能有用,但即便选出了观测峰度最好的方向,也没有证明生成假设成立。本模型不包含测量噪声、非线性混合、源比传感器多或混合矩阵变化等情况。对真实记录提取的分量,还需要领域证据,才能把它命名为某个物理原因。
数值保护条件明确写在程序中。协方差主元须大于输入平方单位下的 1e-12,白化协方差与单位矩阵的误差须不超过 1e-6。因此,代码会拒绝一些数学上有效但尺度太小或病态的数据。这些检查没有添加岭项,也不能让奇异问题变得可辨识。调整尺度可能有帮助;更大的应用需要合适的数值线性代数方法,并认真选择保留维度。非有限输入和检测到的非有限中间结果都会报错。
信任坐标轴之前,先检查假设
- 标准化第二条源。计算它的方差、四阶矩及标准化后的四阶累积量。
逐步计算矩
答案:均值为零,方差为 (4+1+1+4)/4 = 5/2,四阶矩为 (16+1+1+16)/4 = 17/2。将四阶矩除以 (5/2)² 再减去 3,得到 34/25 - 3 = -41/25。所以恢复出的第二个分量的累积量为 −1.64。
- 解释对角线上的失败。四点例子中,为什么零协方差与立即收敛不能确立独立性?
检查非线性矩
答案:协方差只检查两个中心化输出的乘积。独立性还要求它们的平方满足期望分解。这里平方乘积的期望为零,平方期望的乘积为一,因此不独立。立方更新反转了对角线方向;虽然该轴混合了两条源,不区分正负号的方向距离却为零。
- 改变隐藏源的单位。把
s1换成10*s1,原观测能判断哪个尺度才正确吗?
跟踪相应的混合列
答案:将混合矩阵的第一列除以 10,所有观测保持不变。没有额外信息,源的尺度不可辨识。单位方差约定是在选择一种表示,并没有恢复物理单位。仅凭观测也不能确定源的顺序与符号。
- 复用拟合变换。拟合后来了新数据,应当对新批次重新中心化和白化吗?零次迭代预算又能确立什么?
分清预处理和收敛
答案:通过 transform 沿用训练均值、Cholesky 因子和坐标轴;单独白化新批次会改变坐标系。零预算只说明输入通过了实现中的白化检查。返回的初始轴尚未进行 FastICA 更新,状态为 iteration-limit。
从四阶矩走向多种 ICA 对比函数
Hyvärinen 与 Oja 的 1997 年不动点论文提出基于峰度的迭代以及提取多个分量的机制。其收敛分析有明确的源与初始化条件;在一个有限分布上成功,不能把这些保证转移到任意数据集。他们的 2000 年综述将四阶矩方法与负熵、互信息、似然方法放在一起讨论。不同对比函数会改变对源分布和异常值的敏感性。
可以与 PCA 对照:PCA 通过二阶矩选择方向,并按方差排序;ICA 依靠额外的分布假设识别源轴。独立性说明这个更强的目标究竟是什么。NMF追求另一种分解结构,要求因子非负,而不要求源独立。这些数学标准都不能单独赋予分量一个有意义的名称。
先判断,再看解释
两条独立等概率正负一源的对角线使程序报告 converged。可以得出什么?
学习目标
- 区分白化与独立性,解释尺度、符号和排列歧义。
- 在中心化和单位协方差假设下推导立方不动点更新。
- 分别检查已知源恢复与数值停止,并给出仍然依赖的不动点。
先修与延伸
查看知识关联图 →参考文献
- A Fast Fixed-Point Algorithm for Independent Component Analysis
Aapo Hyvärinen; Erkki Oja · 1997 - Independent Component Analysis: Algorithms and Applications
Aapo Hyvärinen; Erkki Oja · 2000
版本1 · 编写状态: 已完成记录中的技术复核
查看技术检查记录(AI)
Codex · 2026-09-05 · Codex technical check: primary-source locations, original runnable models, independent mathematical and computational references, bilingual review and second-agent cross-checks; not independent human peer review.
- 8 项测试通过。独立源坐标累积量比值闭式参照核对 48 次拟合的方向(允许反号)、状态和尝试迭代次数,使用已知混合几何而非逐观测 FastICA 矩。已知逆混合核验源值(允许反号)与重构,理论累积量一致。
- 核对白化矩、新数据复用、生成器输入与输入保留、符号/平移/顺序不变性、收敛但依赖的对角线、精确零四阶累积量更新、零预算、奇异/极小主元和非法/非有限输入。完整输出 6 行。数值保护会主动拒绝部分有效但病态的输入。
- 两语相同代码、4 个对应显示公式、6 锚点、4 答案通过严格 MDX/KaTeX 与真实 React HTML/MathML 检查。测试路径仅由 article_text 设置。原创正文遵循固定 Humanizer 规范。written 记录 AI 作者检查,不是人工审校;未运行生产 ICA 库、噪声数据基准或全站验收。
- Root 完整复读双语、完整程序、四公式和四题答案,重跑作者八项测试及严格 MDX/KaTeX/实际 React HTML;四对应显示式、六标准锚点和四答案通过,无修订要求。
- 独立有限输出水平与完整联合分布检查,验证四个非奇异混合、三个起点共十二次拟合。恢复水平匹配标准化源幅值,在 1e-8 容差合并数值水平后,96 个列联单元均满足边缘乘积;只检查该离散构造例,不把它扩展为任意连续输出的独立性证明。不使用逆混合或作者的累积量比值轨迹参照。
- 五个零更新角度模型,仅源轴方向的水平表独立;三个旋转方向虽已白化,仍不满足完整分解。另复核收敛对角反例、尝试更新次数、拟合预处理复用及明确数值尺度保护。最终五文件 SHA 与冻结清单一致。
- 完整正文、公式、代码和习题迁入;测试只读取正式MDX,删除临时目录回退及草稿跳过,状态断言更新为checked。没有修改算法或独立参照,最终记录绑定两语SHA。
- 出版导航将已发表主题指向完整文章并移除对应待写措辞,未发表目标保留目录入口;原理、公式、程序与习题未改,重新绑定最终正文SHA。
- 出版验证发现仍有草稿状态的子串断言;现解析正式 JSON frontmatter 并要求 checked,不依赖序列化空格。数值测试、参照及正文程序未改。
核对的来源位置:
- A Fast Fixed-Point Algorithm for Independent Component Analysis · Actually downloaded the author-hosted ten-page PDF and viewed pdftoppm images of manuscript pages 2–6: square mixing and ambiguities, fourth cumulant equations (3)–(4), constrained contrast and stationarity equations (5)–(9), §3.1.1 cubic update/normalization/sign-insensitive stop, §3.1.2 multi-component orthogonalization. PDF text encoding was unusable; reading is attributed to the viewed images. The §3.2 proof beyond its opening was not reviewed. Bibliographic year/journal/pages checked against the author’s official FastICA publication list. No universal convergence claim derived from the paper’s informal iteration-count remarks.
- Independent Component Analysis: Algorithms and Applications · Actually read author PDF extracted text: §§2.1–2.2 mixing/ambiguities, §§3.1–3.3 independence versus covariance and Gaussian rotational ambiguity, §4.1 fourth cumulant and outlier sensitivity, §5.2 whitening. Also read located passages on negentropy, mutual information and likelihood for research directions. Official author review.shtml list confirms Neural Networks 13(4–5), 411–430 (2000). The article qualifies nonsingular whitening and nonzero-cumulant requirements instead of repeating informal headings as universal claims.
- A Fast Fixed-Point Algorithm for Independent Component Analysis · Root independently viewed locally rendered original author PDF manuscript pages 4–5: equations 5–9, constrained fourth-cumulant stationarity, §3.1.1 cubic update, normalization and sign-insensitive stopping. The local PDF/images were downloaded/rendered by the author agent; root did not claim a new download or the complete convergence-proof reading. Reviewed the article’s explicit fixed-point counterexample and narrower stopping interpretation.
- Independent Component Analysis: Algorithms and Applications · Root independently opened the author-hosted 31-page review PDF and read extracted text §3.3 lines 229–250: Gaussian rotational ambiguity and the explicit one-Gaussian exception; surrounding nonlinear-moment independence discussion lines 218–228. Reviewed bilingual standardized-source assumptions, invertibility, sign/scale/permutation ambiguities and whitening algebra separately. No full review or benchmark replication claimed.
相关主题