Files
matlab/RBM/PCAwhite.m
T
jens 7b34529b24 imported RBM
git-svn-id: http://moon:8086/svn/matlab/trunk@91 801c6759-fa7c-4059-a304-17956f83a07c
2016-07-12 11:24:12 +00:00

25 lines
622 B
Matlab

function [xpca xzca] = PCAwhite(x)
size(x)
x = x';
k= 10;
epsilon=1e-6;
avg = mean(x, 1)
x = x - repmat(avg, size(x, 1), 1);
sigma = x * x' / size(x, 2);
size(sigma)
[U,S,V] = svd(sigma);
%xRot = U' * x; % rotated version of the data.
%xTilde = U(:,1:k)' * x; % reduced dimension representation of the data,
% where k is the number of eigenvectors to keep
xpca = diag(1./sqrt(diag(S) + epsilon)) * U' * x;
xzca = U * diag(1./sqrt(diag(S) + epsilon)) * U' * x;
close all;
imagesc(sigma); colorbar
figure;
imagesc(x,'EraseMode','none',[-1 1]); colorbar
figure;
imagesc(xpca); colorbar