Updating how the samples per bin are computed and adding an offset, i.e.
the number of samples that are used by the bins before.
A mistake in computing the indices.
New CPU algorithm, solves a bug of the previous version.