Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sth4nth committed Mar 11, 2018
1 parent 7d7c3aa commit 7349e4a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
10 changes: 5 additions & 5 deletions chapter09/linRegEm.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
beta = 0.5;
end
[d,n] = size(X);

I = eye(d);
xbar = mean(X,2);
tbar = mean(t,2);

Expand All @@ -39,12 +39,12 @@
llh(iter) = 0.5*(d*log(alpha)+n*log(beta)-alpha*m2-beta*e2-logdetA-n*log(2*pi)); % 3.86
if abs(llh(iter)-llh(iter-1)) < tol*abs(llh(iter-1)); break; end

V = inv(U);
trS = dot(V(:),V(:)); % A=inv(S)
invU = U'\I;
trS = dot(invU(:),invU(:)); % A=inv(S)
alpha = d/(m2+trS); % 9.63

UX = U'\X;
trXSX = dot(UX(:),UX(:));
invUX = U'\X;
trXSX = dot(invUX(:),invUX(:));
beta = n/(e2+trXSX); % 9.68 is wrong
end
w0 = tbar-dot(m,xbar);
Expand Down
2 changes: 1 addition & 1 deletion chapter10/linRegVb.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
% model: trained model structure
% energy: variational lower bound
% Written by Mo Chen ([email protected]).
[m,n] = size(X);
if nargin < 3
a0 = 1e-4;
b0 = 1e-4;
Expand All @@ -20,6 +19,7 @@
c0 = prior.c;
d0 = prior.d;
end
[m,n] = size(X);
I = eye(m);
xbar = mean(X,2);
tbar = mean(t,2);
Expand Down
2 changes: 1 addition & 1 deletion chapter10/rvmRegVb.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
% model: trained model structure
% energy: variational lower bound
% Written by Mo Chen ([email protected]).
[m,n] = size(X);
if nargin < 3
a0 = 1e-4;
b0 = 1e-4;
Expand All @@ -20,6 +19,7 @@
c0 = prior.c;
d0 = prior.d;
end
[m,n] = size(X);
idx = (1:m)';
dg = sub2ind([m,m],idx,idx);
I = eye(m);
Expand Down
1 change: 0 additions & 1 deletion chapter14/mixLinReg.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
if abs(llh(iter)-llh(iter-1)) < tol*abs(llh(iter)); break; end
end
llh = llh(2:iter);
label = max(R,[],1);
model.alpha = alpha; % mixing coefficient
model.beta = beta; % mixture component precision
model.W = W; % linear model coefficent
Expand Down

0 comments on commit 7349e4a

Please sign in to comment.