Skip to content

Commit 75933f7

Browse files
committed
minor tweak
1 parent d858d5d commit 75933f7

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

chapter12/ppcaVb.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [model, energy] = ppcaVb(X, q, prior)
1+
function [model, L] = ppcaVb(X, q, prior)
22
% Perform variatioanl Bayeisan inference for probabilistic PCA model.
33
% Input:
44
% X: d x n data matrix
@@ -27,7 +27,7 @@
2727
end
2828
tol = 1e-6;
2929
maxIter = 500;
30-
energy = -inf(1,maxIter);
30+
L = -inf(1,maxIter);
3131

3232
mu = mean(X,2);
3333
Xo = bsxfun(@minus, X, mu);
@@ -67,10 +67,10 @@
6767
% Emu = Ebeta/(lambda+n*Ebeta)*sum(X-WZ,2);
6868

6969
% lower bound
70-
energy(iter) = KLalpha+KLbeta+KLW+KLZ;
71-
if energy(iter)-energy(iter-1) < tol*abs(energy(iter-1)); break; end
70+
L(iter) = KLalpha+KLbeta+KLW+KLZ;
71+
if L(iter)-L(iter-1) < tol*abs(L(iter-1)); break; end
7272
end
73-
energy = energy(2:iter);
73+
L = L(2:iter);
7474

7575
model.Z = EZ;
7676
model.W = EW;

demo/ch12/ppcaVb_demo.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
% demos for ch12
2-
32
clear; close all;
43
d = 3;
54
m = 2;
65
n = 1000;
76

87
X = ppcaRnd(m,d,n);
98
plotClass(X);
10-
119
%% Variational Bayesian probabilistic PCA
12-
[model, energy] = ppcaVb(X);
13-
plot(energy);
10+
[model, L] = ppcaVb(X);
11+
plot(L);

0 commit comments

Comments
 (0)