logarithmically spaced integers
Say I have a 10,000 pt vector that I want to take a slice of only 100 logarithmically spaced points. I want a function to give me integer values for the indices. Here's a simple solution that is simply using around + logspace, then getting rid of duplicates. def genLogSpace( array_size, num ): lspace = around(logspace(0,log10(array_size),num)).astype(uint64) return array(sorted(set(lspace.tolist())))-1 ls=genLogspace(1e4,100) print ls.size >>84 print ls array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 17, 19, 21, 23, 25, 27, 30, 33, 37, 40, 44, 49, 54, 59, 65, 71, 78, 86, 94, 104, 114