scikitlearn的FastICA如何去卷积两个分别由高斯噪声组成的信号?

2024-05-16 08:17:53 发布

您现在位置:Python中文网/ 问答频道 /正文

不确定是在这里还是在StackExchange上问这个问题最好,但既然这是一个编程问题,也可能是一个数学问题,那么就来吧。在

问题是关于法斯特卡的。在

给定输入时间序列(以下简称“观测”),其中每个时间序列是n个分量信号的线性混合,ICA返回信号和混合矩阵。从http://www.cs.jhu.edu/~ayuille/courses/Stat161-261-Spring14/HyvO00-icatut.pdf,第3节,我了解到最多一个信号可能是高斯噪声。但下面我似乎证明了FastICA可以恢复两个信号,即使这两个信号都是噪声(这里是时间序列长度的函数,从单个时间步到10000个时间步,对于16个时间序列):

# Snippet below adapted from http://scikit-learn.org/stable/auto_examples/decomposition/plot_ica_blind_source_separation.html
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
from sklearn.decomposition import FastICA, PCA
for i in [1, 2, 3, 4, 5, 10, 20, 100, 1000, 10000]: # number of timepoints
    # Generate sample data
    np.random.seed(0)
    n_samples = i
    time = np.linspace(0, 8, n_samples)
    #
    s1 = np.array([np.random.normal() for q in range(i)])
    s2 = np.array([np.random.normal() for q in range(i)])
    #
    S = np.c_[s1, s2]
    S += 0.2 * np.random.normal(size=S.shape)  # Add extra noise, just to muddy the signals
    #
    S /= S.std(axis=0)  # Standardize data
    # Mix data
    A = np.array([[np.random.normal(), np.random.normal()] for j in range(16)]) # Mixing matrix
    X = np.dot(S, A.T)  # Generate observations
    #
    # Compute ICA
    ica = FastICA(n_components=2)
    print i, "\t",
    try:
        S_ = ica.fit_transform(X)  # Reconstruct signals
    except ValueError:
        print "ValueError: ICA does not run"
        continue
    A_ = ica.mixing_  # Get estimated mixing matrix
    #
    # We can `prove` that the ICA model applies by reverting the unmixing.
    print np.allclose(X, np.dot(S_, A_.T) + ica.mean_) # X - AS ~ 0

输出:

^{2}$

为什么这个有用?一、 为什么X-AS~0(上面的allclose()条件)?注意,如果我们生成的数据集的数量远大于我在这里使用的16个数据集(例如1000个时间序列仍然有效),它仍然有效。在


Tags: infromimportfordata信号np时间