Created
May 19, 2013 13:52
-
-
Save spaghetti-source/5607699 to your computer and use it in GitHub Desktop.
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
% Radial Basis Function expansion | |
% | |
% f(x) = sum k(x, yi) wi | |
% -> w = k(X,Y) \ f(X) | |
% here k(x,y) := rho(|x-y|), e.g., exp(-|x-y2|^2) | |
% input data | |
N = 100; | |
X = rand(N,1); | |
fX = abs( cos( 2 * 3.14 * (X .* X) ) ); | |
% key points | |
M = 10; | |
Y = X(randperm(size(X,1))); | |
Y = X(randperm(size(X,1))); Y = Y(1:M); | |
% estimate | |
beta = 0.1; | |
D = repmat(X,1,size(Y,1))-repmat(Y',size(X,1),1); | |
K = exp( - D .* D / beta ); | |
w = K \ fX; | |
% test | |
S = 1000; | |
Z = [0:1.0/S:1]'; | |
D = repmat(Z,1,size(Y,1)) - repmat(Y',size(Z,1),1); | |
K = exp( - D .* D / beta ); | |
fZ = K * w; | |
xlim([0,1]); | |
plot(X, fX, 'r.'); | |
hold on; | |
plot(Z, fZ, 'b-'); | |
hold off; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment