一、简介
1 基础概念
FastICA算法,又称不动点(Fixed-Point)算法,是由芬兰赫尔辛基大学Hyvärinen等人提出来的。是一种快速寻优迭代算法,与普通的神经网络算法不同的是这种算法采用了批处理的方式,即在每一步迭代中有大量的样本数据参与运算。但是从分布式并行处理的观点看该算法仍可称之为是一种神经网络算法。
FastICA算法有基于峭度、基于似然最大、基于负熵最大等形式,这里,我们介绍基于负熵最大的FastICA算法(可以有效地把不动点迭代所带来的优良算法特性与负熵所带来的更好统计特性结合起来)。它以负熵最大作为一个搜寻方向,可以实现顺序地提取独立源,充分体现了投影追踪(Projection Pursuit)这种传统线性变换的思想。此外,该算法采用了定点迭代的优化算法,使得收敛更加快速、稳健。
因为FastICA算法以负熵最大作为一个搜寻方向,因此先讨论一下负熵判决准则。由信息论理论可知:在所有等方差的随机变量中,高斯变量的熵最大,因而我们可以利用熵来度量非高斯性,常用熵的修正形式,即负熵。根据中心极限定理,若一随机变量由许多相互独立的随机变量之和组成,只要具有有限的均值和方差,则不论其为何种分布,随机变量较更接近高斯分布。换言之,较的非高斯性更强。因此,在分离过程中,可通过对分离结果的非高斯性度量来表示分离结果间的相互独立性,当非高斯性度量达到最大时,则表明已完成对各独立分量的分离[1]。
2 负熵的定义:
3 算法原理
4 算法步骤
二、源代码
clc
clear all
%% --------------------------------- Set Parameters
N = 1; %The number of observed mixtures
Ns = 2; %The number of independent sources
Ls = 1000; %Sample size, i.e.: number of observations
finalTime = 40*pi; %Final sample time (s)
initialTime = 0; %Initial sample time (s)
%% --------------------------------- Generating Data for SSA-ICA
Amix = rand(N,Ns); %Amix is a random N x Ns mixing matrix
timeVector = initialTime:(finalTime-initialTime)/(Ls-1):finalTime; %Vector of time coordinates
source1 = sin(1.1*timeVector); %Independent source component 1, sin(a * t)
source2 = cos(0.25*timeVector); %Independent source component 2, cos(b * t)
S = [source1;source2]; %Source Matrix
figure
plot(timeVector,source1) %Plotting the N independent sources vs. time
xlabel('time (s)')
ylabel('Signal Amplitude')
legend('source 1')
figure
plot(timeVector,source2) %Plotting the N independent sources vs. time
xlabel('time (s)')
ylabel('Signal Amplitude')
legend('source 2')
Yobs = Amix*S; %Matrix consisting of M samples of N observed mixtures
figure
plot(timeVector,Yobs) %Plotting the observed signal vs. time
xlabel('time (s)')
ylabel('Signal Amplitude')
legend('observed signal')
function [Sest] = Fast_ICA(Xobs,C)
%% Preprocessing, Centering
SX = size(Xobs);
N = SX(1);
M = SX(2);
X = Xobs'; %X is the transpose of the matrix of M samples of N mixtures, used in subsequent calculations
Xmean = mean(X); %Xmean is the mean vector of the matrix X
for i = 1:N
X(:,i) = X(:,i) - Xmean(i); %The matrix X is centered by subtracting each of the N mixtures by their corresponding sample averages
end
%% Preprocessing, Whitening
ExxT = cov(X); %The covariance matrix of X is computed and stored in ExxT
[E,D] = eig(ExxT); %Eigenvalue decomposition is applied on the covariance matrix of X, ExxT
Z = E*1/sqrt(D)*E'*X'; %The matrix X is whitened to Z
%% FastICA algorithm
W = 0.5*ones(C,N); %Initializing W, a matrix consisting of columns corresponding with the inverse of the (transformed) mixing Amix
iterations = 100; %The amount of iterations used in the fastICA algorithm
for p = 1:C
wp = ones(N,1)*0.5;
wp = wp / sqrt(wp'*wp);
for i = 1:iterations
G = tanh(wp'*Z);
Gder = 1-tanh(wp'*Z).^2;
wp = 1/M*Z*G' - 1/M*Gder*ones(M,1)*wp;
dumsum = zeros(C,1);
for j = 1:p-1
dumsum = dumsum + wp'*W(:,j)*W(:,j);
end
wp = wp - dumsum;
wp = wp / sqrt(wp'*wp);
end
W(:,p) = wp;
end
%% Output Results
W = W/sqrt(2); %The factor sqrt(2) is an emirical constant added to make the predictions fit the data properly. The source of the factor has yet to be determined.
Sest = W'*Z;
end
三、运行结果
四、备注
版本:2014a
完整代码或代写加1564658423