Regarding First Numpy Exercise

Please refer the course material from WEEK 8 - NumPy to understand the problem better, I was not able to write the entire code or the problem statement

This is regarding one of the Numpy exercises on Week 8.
Problem : To find the number of data that are present outside the circle of radius 1 for 2D and other higher order Dimensions

def area_outside_square(npoints,ndim):
    points = np.random.rand(npoints,ndim)
    return np.sum(np.sqrt(np.sum(points*points ,axis = 1)))

This was the function which returns the no of points outside radius 1

for i in range(2,11):
   print(i, area_outside_square(100000,i))

This was function call for it

Correct me if I’m wrong but the input here is only two dimensions and ouput is for different columns right ?
But in the course, it was conveyed as different dimensions…Can anyone clarify me on that ?

Check this thread(see if it helps):

1 Like

So, each higher dimensional points can be viewed upon as number of 2D structures put together and so it doesn’t matter whether what the no of n is n-D, it can always be going to be simple 2D array and so addition along the column makes sense i.e axis = 1 and so only the no of columns is enough to recreate a part of the entire 2D. Say if we need 10D, just give 10 columns and it’ll represent a part of 10-D . Am i understanding it right ?

Is that what you’re saying ?

Yes. For eg [x, y] represents a point in 2-d and [x, y, z] represents a point in 3-d.

1 Like

Duplicate of Multi-dimensional coordinate points and multi-dimensional array representation