Multi-dimensional coordinate points and multi-dimensional array representation

In the function defined above the axis was kept = 1 which in case of two dimensional arrays is true for column wise addition of points but in case of three dimensional array or higher, the axis for column addition changes right , it will be =2 since in order the first is the dimension the second is the row and the third is the column.
So therefore incase of the for loop where sir used it to get the answer for the higher dimension, it should be changed to axis=2 for 3rd and higher dimensions.

As you can see from the above example from what i meant.

A point can be in 1-d, 2-d, 3-d… or n dimension but the representation can always be done by a 2-d matrix/array.

For e.g. a single pt x= [2, 4, 6, 7, 8] represents a point in five dimension using a 2-d matrix/array (rows: 1, columns 5).
if we have 2 points x1 = [2, 4, 6, 7, 8] and x2 = [1, 3, 5, 7, 9], we can represent using a 2-d matrix/array as
[ [2, 4, 6, 7, 8],
[1, 3, 5, 7, 9]]
where each row represents a point in 5-dimension.

If you look at the code:
points = np.random.ran(npoints, ndim)
points, is again a 2-d matrix/array, so the use of axis=1 is correct.
Hope it makes sense.

bro in the for loop the ndim is changing so is the dimensionality of the points(which is the array in the code), and for ndim equals 3 and so on the axis for column addition changes to 2, which you can see in the jupiter notebook example where i have taken a 3 dimensional array and used column addition with axis =2;

hope it makes sense

c.shape (from your code) is 3 element tuple.
points.shape from code written by sir is a 2 element tuple (representing 100 points each of 1000 dimension)

May be I don’t understand your question. Any thoughts why c.shape has more elements than points.shape?

ofcourse :slight_smile:

1 Like