Fixed the bug in compute centroids function
The index was stride, rather than incrementing a loop counter; woops.