Skip to content

Commit 91cefe8

Browse files
committed
add ldsPca
1 parent d1a3ae6 commit 91cefe8

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

chapter13/LDS/ldsPca.m

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
% Input:
44
% X: d x n data matrix
55
% k: dimension of hidden variable
6-
% m:
6+
% m: stacking order for the Hankel matrix
77
% Output:
8-
% A:
9-
% C:
10-
% Z:
8+
% A: k x k transition matrix
9+
% C: k x d emission matrix
10+
% Z: k x n latent variable
11+
% Y: d x n reconstructed data
1112
% reference: Bayesian Reasoning and Machine Learning (BRML) chapter 24.5.3 p.507
12-
% Written by Mo Chen (sth4nth@gmail.com).
13+
% Written by Mo Chen (sth4nth@gmail.com).
14+
[d,n] = size(X);
15+
H = reshape(X(:,hankel(1:m,m:n)),d*m,[]);
16+
[U,S,V] = svd(H,'econ');
17+
C = U(1:d,1:k);
18+
Z = S(1:k,1:k)*V(:,1:k)';
19+
A = Z(:,2:end)/Z(:,1:end-1); % estimated transition
20+
% Y = C*Z; % reconstructions

0 commit comments

Comments
 (0)