function [cost] =  BasisError(X,V,V_inv,m,p);

[d, n] = size(X);
% Basis representation of the mean
m1 = V*V_inv*m;

cost = 0;

if(p==1)
  cost=sum(sum(abs(X-m1*ones(1,n))));
else
  cost=sum(sum((X-m1*ones(1,n)).^2));
end
