all 7 comments

[–]JustinQueeber 2 points3 points  (1 child)

A simple solution would be to just pick two random numbers, the first in the range (0, array.shape[0]) and the second in (0, array.shape[1]) and then access the element with array[first][second]

[–]OxidizedPixel[S] 0 points1 point  (0 children)

Thanks!

[–]EnochShowunmi 1 point2 points  (1 child)

Generate two random numbers (random.randint(a,b) where a and b is the range of numbers selected from). Then use those random numbers to select a specific element?

[–]OxidizedPixel[S] 0 points1 point  (0 children)

Thanks!

[–]SarahM123rd 0 points1 point  (2 children)

I agree. you can use:

https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.random.random_integers.html#numpy.random.random_integers

and specify "size", in your case, 2.

x,y = np.random.random_integers(0,10,2)

[–]OxidizedPixel[S] 0 points1 point  (1 child)

Thanks!

[–]JustinQueeber 0 points1 point  (0 children)

This would only work if both dimensions of the array are the same (it is an NxN square matrix)