clear all;
clc;

t = 0:0.1:2*pi;
X = [sin(t)', cos(t)', (exp(-0.4*t) .* sin(t))', 0.5 * randn(numel(t),1)];

figure;
plot (X);

X = X';
[ Y, W, R, R_hat, X_hat ] = pca_transform( X, 4);

figure;
plot (X_hat');


% bledy odtworzen
er = norm (R - R_hat) % bezwzgledny
der = er / norm (R) % wzgledny
ex = norm (X - X_hat)
dex = ex / norm (X)