function Y = transform(X, centres, widths)
% input transformations

[N,dimx] = size(X);
[Nm,dummy] = size(centres);

if Nm == 1
   weightings = ones(N,1);
   return
end
basis = zeros(N,Nm);

for m=1:Nm
   dist = (X-ones(N,1)*centres(m,:));
    if dimx > 1
       basis(:,m) = exp(-sum((dist.*(ones(N,1)*(1./widths(m,:))).*dist)')');
    else
       basis(:,m) = exp(-dist.^2./widths(m));
    end
end

%unnorm = basis.*(basis > 0.01);
%basis = basis./(eps+sum(basis')'*ones(1,weights.Nm));
Y = basis;