Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Flore W4,731 Points
Quiz question on rank of matrix
The quiz asks what the rank of the below matrix is:
ratings = np.array([ [5, 4, 5, 5, 2], [5, 5, 5, 5, 4], [1, 2, 1, 1, 1] ])
The response is 2 - I agree that the dimension of the matrix is 2, but the rank is different from its dimension.
Wikipedia defines rank as the number of columns that are linearly independent. In which case it would be 3 for this matrix. Is there a different definition in coding?
Chris FreemanTreehouse Moderator 68,064 Points
Good question! Rank is such an overused term, it's easy to mix up the overlapping definitions.
On Wikipedia, the is also Rank (computer programming) which says "
In computer programming, rank with no further specifications is usually a synonym for (or refers to) "number of dimensions"; thus, a two-dimensional array has rank two, a three-dimensional array has rank three and so on."
In older versions of NumPy, the was a
rank() function, where "rank" used to mean the number of linearly independent rows (that is, it's dimensions). A matrix is 2-dimensional, and would have a "rank" of 2.
In NumPy 1.9.0, the
rank() function was deprecated and is not longer used.
np.ndim() is now the suggested way to get the dimension of an array.
Post back if you have more questions. Good Luck!!