function s=scoreMCE(x,y,k)
% score the assignments against the data
[n,d]=size(y);
% calculate centroids
for i=1:k,
    m(i)=sum(x(x==i));
    
    for j=1:d,
        if m(i)>0,
            c(i,j)=mean(y(x==i,j));
        else
            c(i,j)=0;
        end
    end
end

% Score the assignment

for j=1:d,
    qq(:,j)=(y(:,j)-c(x,j)).^d;
end
s=sum((sum(qq,2)).^(1/d));
