pca_apply

PURPOSE ^

Companion function to pca.

SYNOPSIS ^

function [ Yk, Xhat, avsq, avsq_orig ] = pca_apply( X, U, mu, variances, k )

DESCRIPTION ^

 Companion function to pca.

 Use pca to retrieve the principal components U and the mean mu from a
 set fo vectors X1 via [U,mu,variances] = pca(X1).  Then given a new
 vector x, use y = pca_apply( x, U, mu, variances, k ) to get the first k
 coefficients of x in the space spanned by the columns of U.

 The input x can be a matrix X, where each column represents a single
 vector in R^N.  If X has higher dimension, the first n-1 dimensions are
 used as the variables and the last dimension as an observation -- for
 more information on this see pca.m

 This may prove useful:
   siz = size(X);  k = 100;
   Uim = reshape( U(:,1:k), [ siz(1:end-1) k ]  );

 It is also interesting to look at the distribution of the points Y's (their projection
 onto 2D or 3D): 
   plot( Y(1,:), Y(2,:), '.' );
   plot3( Y(1,:), Y(2,:), Y(3,:), '.' );

 INPUTS
   X           - array for which to get PCA coefficients
   U           - [returned by pca] -- see pca
   mu          - [returned by pca] -- see pca
   variances   - [returned by pca] -- see pca
   k           - number of principal coordinates to approximate X with

 OUTPUTS
   Yk          - first k coordinates of X in column space of U
   Xhat        - approximation of X corresponding to Yk
   pixelerror  - measure of squared error per pixel normalized to fall between [0,1]

 DATESTAMP
   29-Nov-2005  2:00pm

 See also PCA, PCA_APPLY_LARGE, PCA_VISUALIZE

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Wed 03-May-2006 23:48:50 by m2html © 2003