forked from aludnam/MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_alg4.m
31 lines (27 loc) · 955 Bytes
/
user_alg4.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
%THIS FUMCTION ILLUSTRATES HOW TO USE THE USER-DEFINED ALGORITHM
function [AH,XH] = user_alg4(Y,r,X)
%
% The example of implementing the user-defined algorithm (this is the Lee-Seung algorithm based on the KL divergence)
%
% INPUTS:
% Y - mixed signals (matrix of size [m by T])
% r - number of estimated signals
% X - true source signals
%
% OUTPUTS
% AH - estimated mixing matrix (matrix of size [m by r])
% XH - estimated source signals (matrix of size [r by T])
%
% #########################################################################
% Initialization
[m,T]=size(Y);
Y(Y <=0) = eps; % this enforces the positive value in the data
AH=rand(m,r);
XH=rand(r,T);
IterNo = 1000; % number of alternating steps
% Iterations
for k = 1:IterNo
XH = XH.*(AH'*(Y./(AH*XH + eps)));
AH = AH.*((Y./(AH*XH + eps))*XH')./repmat(sum(XH,2)',m,1);
AH = AH*diag(1./(sum(AH,1) + eps));
end