Skip to content

Commit

Permalink
refactorized plotCurveBar
Browse files Browse the repository at this point in the history
  • Loading branch information
sth4nth committed Feb 22, 2016
1 parent c526f03 commit bb73942
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 90 deletions.
23 changes: 19 additions & 4 deletions chapter03/demo.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,28 @@
[x,t] = linRnd(d,n);
%% Linear regression
model = linReg(x,t);
linPlot(model,x,t);
[y,sigma] = linRegPred(model,x,t);
plotCurveBar( x, y, sigma );
hold on;
plot(x,t,'o');
hold off;
%% Empirical Bayesian linear regression via EM
[model1,llh] = linRegEm(x,t);
plot(llh);
linPlot(model,x,t);
[y,sigma] = linRegPred(model,x,t);
figure
plotCurveBar( x, y, sigma );
hold on;
plot(x,t,'o');
hold off;
%% Empirical Bayesian linear regression via Mackay fix point iteration method
[model,llh] = linRegFp(x,t);
[y, sigma] = linRegPred(model,x,t);
plot(llh);
linPlot(model,x,t);
[y,sigma] = linRegPred(model,x,t);
figure
plotCurveBar( x, y, sigma );
hold on;
plot(x,t,'o');
hold off;
%%

18 changes: 0 additions & 18 deletions chapter03/linPlot.m

This file was deleted.

65 changes: 30 additions & 35 deletions chapter07/demo1.m
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
%% regression
% d = 100;
% beta = 1e-1;
% X = rand(1,d);
% w = randn;
% b = randn;
% t = w'*X+b+beta*randn(1,d);
%
% x = linspace(min(X)-1,max(X)+1,d); % test data
%
d = 100;
beta = 1e-1;
X = rand(1,d);
w = randn;
b = randn;
t = w'*X+b+beta*randn(1,d);
x = linspace(min(X),max(X),d); % test data


%% RVM regression by Mackay fix point update
% [model,llh] = rvmRegFp(X,t);
% figure
% plot(llh);
% [y, sigma] = linRegPred(x,model,t);
% figure;
% hold on;
% plotBand(x,y,2*sigma);
% plot(X,t,'o');
% plot(x,y,'r-');
% hold off
%%
% [model,llh] = rvmRegEm(X,t);
% [y, sigma] = linRegPred(model,x,t);
% figure
% plot(llh);
% [y, sigma] = linRegPred(x,model,t);
% figure;
% plotCurveBar(x,y,sigma);
% hold on;
% plotBand(x,y,2*sigma);
% plot(X,t,'o');
% plot(x,y,'r-');
% hold off
%%
% [model,llh] = rvmRegSeq(X,t);
% figure
% plot(llh);
% [y, sigma] = linRegPred(x,model,t);
% figure;
% hold on;
% plotBand(x,y,2*sigma);
% plot(X,t,'o');
% plot(x,y,'r-');
% hold off
%% RVM regression by EM
[model,llh] = rvmRegEm(X,t);
plot(llh);
[y, sigma] = linRegPred(model,x,t);
figure
plotCurveBar(x,y,sigma);
hold on;
plot(X,t,'o');
hold off
%% RVM regression by sequential update
[model,llh] = rvmRegSeq(X,t);
plot(llh);
[y, sigma] = linRegPred(model,x,t);
figure
plotCurveBar(x,y,sigma);
hold on;
plot(X,t,'o');
hold off
61 changes: 29 additions & 32 deletions chapter10/demo.m
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
% demos for ch10
% chapter10/12: prediction functions for VB
%% regression
% clear; close all;
%
% d = 100;
% beta = 1e-1;
% X = rand(1,d);
% w = randn;
% b = randn;
% t = w'*X+b+beta*randn(1,d);
% x = linspace(min(X)-1,max(X)+1,d); % test data
%
% [model,llh] = linRegVb(X,t);
% % [model,llh] = rvmRegVb(X,t);
% figure
% plot(llh);
% [y, sigma] = linRegPred(model,x);
% figure;
% hold on;
% plotBand(x,y,2*sigma);
% plot(X,t,'o');
% plot(x,y,'r-');
% hold off
clear; close all;

d = 100;
beta = 1e-1;
X = rand(1,d);
w = randn;
b = randn;
t = w'*X+b+beta*randn(1,d);
x = linspace(min(X)-1,max(X)+1,d); % test data

[model,llh] = linRegVb(X,t);
% [model,llh] = rvmRegVb(X,t);
plot(llh);
[y, sigma] = linRegPred(model,x,t);
figure
plotCurveBar(x,y,sigma);
hold on;
plot(X,t,'o');
hold off
%% Variational Bayesian for Gaussian Mixture Model
close all; clear;
d = 2;
k = 3;
n = 2000;
[X,label] = mixGaussRnd(d,k,n);
plotClass(X,label);
[y, model, L] = mixGaussVb(X,10);
figure;
plotClass(X,y);
figure;
plot(L)
% close all; clear;
% d = 2;
% k = 3;
% n = 2000;
% [X,label] = mixGaussRnd(d,k,n);
% plotClass(X,label);
% [y, model, L] = mixGaussVb(X,10);
% figure;
% plotClass(X,y);
% figure;
% plot(L)


2 changes: 1 addition & 1 deletion chapter13/HMM/demo.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% demo
% demos for HMM in ch13

d = 3;
k = 2;
Expand Down
2 changes: 2 additions & 0 deletions chapter13/LDS/demo.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
% 1) test against matlab implementation of kalman filter
% 2) simplify ldsEm with less parameters (G=diag(g), S=I)

% demos for LDS in ch13

clear; close all;
d = 3;
k = 2;
Expand Down

0 comments on commit bb73942

Please sign in to comment.