Main Content

Extract Mixed Signals

此示例显示了如何使用r解散混合音频信号。您可以使用r在包括预处理步骤时,执行独立分量分析(ICA)。ICA模型是

$$ x = \ mu +作为。$$

这里,$x$是A.$ p $.-by-1 vector of mixed signals,$\mu$是A.$ p $.-by-1 vector of offset values,$ a $是A.$ p $.-by-$ q $混合矩阵,和$ s $是A.$ q $-1原始信号的1向量。首先假设$ a $是一个方形矩阵。如果你知道的话$\mu$一个nd$ a $,您可以恢复原始信号$ s $from the data$x$

$$ s = a ^ { -  1}(x  -  \ mu)。$$

使用rfunction, you can perform this recovery even without knowing the mixing matrix$ a $or the mean$\mu$。Given a set of several observations$ x(1)$$ x(2)$,......,r提取原始信号$ s(1)$$ s(2)$,......

加载数据

加载一组六个音频文件,使用MATLAB®送货。将每个文件修剪到10,000个样本。

files = {'chirp.mat''gong.mat''handel.mat''laughter.mat''splat.mat''train.mat'}; S = zeros(10000,6);对于i = 1:6 test = load(文件{i});y = test.y(1:10000,1);s(:,i)= y;结束

混合信号

Mix the signals together by using a random mixing matrix and add a random offset.

rng默认% For reproducibilitymixdata = S*randn(6) + randn(1,6);

To listen to the original sounds, execute this code:

对于i = 1:6 disp(i);声音(S(:,i));暂停;结束

To listen to the mixed sounds, execute this code:

对于i = 1:6 disp(i);声音(mixdata(:,i));暂停;结束

Plot the signals.

数字对于i = 1:6子图(2,6,i)绘图(s(:,i))标题(['声音',num2str(i)])子图(2,6,i + 6)绘图(Mixdata(:,i))标题(['Mix ',num2str(i)])结束

原始信号结构明显。混合信号结构较少。

预浪混合信号

To separate the signals effectively, "prewhiten" the signals by using theprewhitenfunction that appears at the end of this example. This function transformsmixdata因此它具有零均值和身份协方差。

这个想法是下面的。如果$ s $是A.zero-mean source with statistically independent components, then

$$E(s) = 0$$

$$E(ss^T) = I.$$

然后the mean and covariance of$x$

$$ E(x) = \mu$$

$$ {\ rm cov}(x)= aa ^ t = c。$$

假设你知道$\mu$一个nd$C$。在实践中,您可以从列的样本和协方差估计这些数量$x$。你可以解决$ s $就......而言$x$通过

$$ s = a ^ { -  1}(x-\ mu)=(a ^ ta)^ { -  1} a ^ t(x-\ mu)。$$

后一程等式甚至持续$ a $不是方形可逆的矩阵。

假设$U$是A.$ p $.-by-$ q $正半纤维矩阵的左特征向量矩阵$C$那一个nd$\Sigma$is the$ q $-by-$ q $特征值的矩阵。然后

$$ c = u \ sigma u ^ t $$

$$ u ^ tu = i。$$

然后

$$ aa ^ t = u \ sigma u ^ t。$$

There are many mixing matrices$ a $满足最后一个等式。如果$W$是A.$ q $-by-$ q $正常的矩阵,然后

$$ w ^ tw = w w ^ t =我$$

$$ a = u \ sigma ^ {1/2} w。$$

Substituting into the equation for$ s $

$$s = W^T\tilde{x},\ \rm{where}$$

$$ \tilde{x} = \Sigma^{-1/2}U^T(x-\mu).$$

$\tilde{x}$is the prewhitened data.r计算未知矩阵$W$在假设的情况下$ s $是一个s independent as possible.

mixdata = prewhiten(mixdata);

分开所有信号

超高斯源具有接近零的尖峰,例如声音1的直方图。

图表直方图(S(:,1))

在询问六个功能时执行重建ICA。表明每个来源是超级高斯。

q = 6;mdl = rica(mixdata,q,'NonGaussianityIndicator',(6,1));

Extract the features. If the unmixing procedure is successful, the features are proportional to the original signals.

解密=转换(MDL,MIXDATA);

将解密的信号与原始信号进行比较

绘制原始和解密的信号。

数字对于i = 1:6子图(2,6,i)绘图(s(:,i))标题(['声音',num2str(i)])子图(2,6,i + 6)plot(解密(:,i))标题(['Unmix ',num2str(i)])结束

解密信号的顺序与原始顺序不同。重新排序列,以便未混合信号与相应的原始信号匹配。缩放未混合信号以具有与相应的原始信号相同的规范。(r无法识别原始信号的比例,因为任何刻度都可以导致相同的信号混合。)

解密=解密(:,[2,5,4,6,3,1]);对于i = 1:6 unmixed(:,i) = unmixed(:,i)/norm(unmixed(:,i))*norm(S(:,i));结束

绘制原始和解密的信号。

数字对于i = 1:6 subplot(2,6,i) plot(S(:,i)) ylim([-1,1]) title(['声音',num2str(i)])subplot(2,6,i+6) plot(unmixed(:,i)) ylim([-1,1]) title(['Unmix ',num2str(i)])结束

解密信号看起来类似于原始信号。要收听解密声音,请执行此代码。

对于i = 1:6 disp(i);声音(解密(:,i));暂停;结束

这是代码prewhiten功能。

functionZ = prewhiten(X)% X = N-by-P matrix for N observations and P predictors% Z = N-by-P prewhitened matrix%1. X的大小。[n,p] = size(x);断言(n> = p);% 2. SVD of covariance of X. We could also use svd(X) to proceed but N% can be large and so we sacrifice some accuracy for speed.[u,sig] = svd(cov(x));sig = diag(sig);sig = sig(:)';%3.找出SIG的值是非零的。托尔=每股收益(类(X));idx = (Sig > max (Sig) * tol);一个ssert(~all(idx == 0));%4.获取SIG和U的相应列的非零元素。Sig = Sig(idx); U = U(:,idx);%5.计算预良数据。mu = mean(X,1); Z = bsxfun(@minus,X,mu); Z = bsxfun(@times,Z*U,1./sqrt(Sig));结束

也可以看看

|||

相关例子

更多关于