# pcaApply

## PURPOSE

Companion function to pca.

## SYNOPSIS

function varargout = pcaApply( X, U, mu, k )

## DESCRIPTION

     Companion function to pca.

     Use pca.m to retrieve the principal components U and the mean mu from a
     set of vectors x, then use pcaApply to get the first k coefficients of
     x in the space spanned by the columns of U. See pca for general usage.

     If x is large, pcaApply first splits and processes x in parts. This
     allows pcaApply to work even for very large arrays.

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

     USAGE
      [ Yk, Xhat, avsq ] = pcaApply( X, U, mu, k )

     INPUTS
      X           - data for which to get PCA coefficients
      U           - returned by pca.m
      mu          - returned by pca.m
      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
      avsq        - measure of squared error normalized to fall between [0,1]

     EXAMPLE

     See also PCA, PCAVISUALIZE

     Piotr's Image&Video Toolbox      Version 2.0
     Copyright 2012 Piotr Dollar.  [pdollar-at-caltech.edu]
     Please email me if you find bugs, or have suggestions or questions!
     Licensed under the Simplified BSD License [see external/bsd.txt]