Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added function that does the equivalent of orthogonal projection for …
…kernels, for some ideas on nonlinear sysid I want to try.
- Loading branch information
Showing
5 changed files
with
24 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
function [x y] = gen_glm(A,B,C,f,b,x0,u,Q) | ||
|
||
n = size(x0,1); | ||
x = zeros(n,size(u,2)); | ||
T = size(u,2); | ||
x = zeros(n,T); | ||
|
||
if isempty(Q) | ||
Q = zeros(n); | ||
end | ||
|
||
x(:,1) = x0; | ||
E = chol(Q); | ||
for i = 1:size(u,2) | ||
for i = 1:T | ||
e = E*randn(n,1); | ||
if i < size(u,2) | ||
x(:,i+1) = A*x(:,i) + B*u(:,i) + e(1:n); | ||
end | ||
end | ||
|
||
y = poissrnd( f( C*x + b ) ); | ||
y = poissrnd( f( C*x + b*ones(1,T) ) ); |
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function ku = orth_kernel(k,U) | ||
% given a kernel k(x,x') and a matrix U, construct a kernel ku that is the | ||
% inner product in the orthogonal projection of U in feature space. That | ||
% is, ku(x,u) = 0 for all x and u such that u is a column of U. | ||
|
||
Kuu = zeros(size(U,2)); | ||
for i = 1:size(U,2) | ||
for j = 1:size(U,2) | ||
Kuu(i,j) = k(U(:,i),U(:,j)); | ||
end | ||
end | ||
invKuu = Kuu^-1; | ||
ku = @(x,y) k(x,y) - kux(x,U,k)'*invKuu*kux(y,U,k); | ||
|
||
function z = kux(x,U,k) | ||
z = zeros(size(U,2)); | ||
for i = 1:size(U,2) | ||
z(i) = k(x,U(:,i)); | ||
end |
File renamed without changes.