function qzs = equipartition(zs, nbins)
    N = numel(zs);
    A = [zs(:), (1:N)'];
    B = sortrows(A);
    indexes = B(:,2);
    x = floor(((1:N)-1)*(nbins/N));
    qzs(indexes,1) = x;
end