The Difference between the type of Data Structure, and shapes of (R,1) & (R,)

I saw that many confused about difference between of (R,1) and (R,) shapes and the data structures it’s belong

It 's turn out the the shape of (R,) is called a rank of 1 array in python also it neither of row vector nor column vector, it’s not recommend to use it as it has a bad and wrong thing like this image I made

which show that the X also equal the transpose of X and that’s wrong, also if we take dot product we waiting for matrix but it will lead to just number,

But

First Using X=X[:, np.newaxis], you can convert the shape (R,) to column vector with shape (R,1).
IF we use the shape (R,1) it’s called and columns vector like this image

it’s an correct one as the transpose of X(row vector) isn’t equal X, in addition to the dot product (outer product)of two vector will lead to matrix and that’s more powerful and more recommend in the python vector implementation

So briefly,
An array with a size of (R,1) is a 2D array containing empty columns that’s recommended, and powerful.
An array with a size of (R,) is a 1D array.

Cheers,
Abdelrahman

3 Likes

Great post, Abdelrahman!

1 Like