Can you create a numpy array with all unique values in it?
myArray = numpy.random.random_integers(0,100,2500)
myArray.shape = (50,50)
So here I have a given random 50x50 numpy array, but I could have non-unique values. Is there a way to ensure every value is unique?
Thank you
Update:
I have created a basic function to generate a list and populate a unique integer.
dist_x = math.sqrt(math.pow((extent.XMax - extent.XMin), 2))
dist_y = math.sqrt(math.pow((extent.YMax - extent.YMin),2))
col_x = int(dist_x / 100)
col_y = int(dist_y / 100)
if col_x % 100 > 0:
col_x += 1
if col_y % 100 > 0:
col_y += 1
print col_x, col_y, 249*169
count = 1
a = []
for y in xrange(1, col_y + 1):
row = []
for x in xrange(1, col_x + 1):
row.append(count)
count += 1
a.append(row)
del row
numpyArray = numpy.array(a)
Is there a better way to do this?
Thanks
np.random.permutation(np.arange(N))
? – ojy Aug 18 '14 at 18:04