def pca(pArray, iComponents=1):
    """
	Input: N x D matrix 
	Output: D x N matrix 
	
	"""
    from sklearn.decomposition import PCA
    pPCA = PCA(n_components=iComponents)
    pcs = pPCA.fit_transform(pArray.T).T
    loadings = pPCA.components_
    return pcs[0], pPCA.explained_variance_ratio_[0], loadings[0]
