Last active
May 1, 2019 18:18
-
-
Save vtta/f94f71bb8a1c39d6116de84300b473b5 to your computer and use it in GitHub Desktop.
simple K-L transform algorithm implemented in Octave
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
function Y=KLTransform(X, d) | |
[sampleNum, featureNum] = size(X); | |
m = mean(X); | |
for i = 1:sampleNum | |
X(i,:) = X(i,:) - m; | |
end | |
C = cov(X); | |
[V, D] = eig(C); | |
S = [diag(D), V]; | |
S = sortrows(S, -1); | |
S = S(1:d, 2:end); | |
Y = (S*X')'; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment