'compute the SVD of a and store data for PCA.  Use project to
project the data onto a reduced set of dimensions
Parameters
a : np.ndarray
A numobservations x numdims array
standardize : bool
True if input data are to be standardized. If False, only centering
will be carried out.
Attributes
a
A centered unit sigma version of input ``a``.
numrows, numcols
The dimensions of ``a``.
mu
A numdims array of means of ``a``. This is the vector that points
to the origin of PCA space.
sigma
A numdims array of standard deviation of ``a``.
fracs
The proportion of variance of each of the principal components.
s
The actual eigenvalues of the decomposition.
Wt
The weight vector for projecting a numdims point or array into
PCA space.
Y
A projected into PCA space.
Notes
The factor loadings are in the ``Wt`` factor, i.e., the factor loadings
for the first principal component are given by ``Wt[0]``. This row is
also the first eigenvector.'

def __init__(self, a, standardize=True):

    (n, m) = a.shape
    if (n < m):
        raise RuntimeError(u'we    assume    data    in    a    is    organized    with    numrows>numcols')
    (self.numrows, self.numcols) = (n, m)
    self.mu = a.mean(axis=0)
    self.sigma = a.std(axis=0)
    self.standardize = standardize
    a = self.center(a)
    self.a = a
    (U, s, Vh) = np.linalg.svd(a, full_matrices=False)
    self.Wt = Vh
    Y = np.dot(Vh, a.T).T
    self.Y = Y
    self.s = (s ** 2)
    vars = (self.s / float(len(s)))
    self.fracs = (vars / vars.sum())
