forked from PRML/PRMLT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
% demo | ||
% demos for HMM in ch13 | ||
|
||
d = 3; | ||
k = 2; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters