don't understand matrix-multiplication should be reversed in python?

PythonDude mjoerg.phone at gmail.com
Thu Nov 12 10:57:51 EST 2015


Hi all,

I've come around a webpage with python-tutorial/description for obtaining something and I'll solve this:

R = p^T w

where R is a vector and p^T is the transpose of another vector.

...
p is a Nx1 column vector, so p^T turns into a 1xN row vector which can be multiplied with the
Nx1 weight (column) vector w to give a scalar result. This is equivalent to the dot
product used in the code. Keep in mind that Python has a reversed definition of
rows and columns and the accurate NumPy version of the previous equation would
be R = w * p.T
...

(source: http://blog.quantopian.com/markowitz-portfolio-optimization-2/ )

I don't understand this: "Keep in mind that Python has a reversed definition of
rows and columns and the accurate NumPy version of the previous equation would
be R = w * p.T"

Not true for numpy, is it? This page: http://mathesaurus.sourceforge.net/matlab-numpy.html says it python and matlab looks quite similar...

Anyone could please explain or elaborate on exactly this (quote): "Keep in mind that Python has a reversed definition of rows and columns"???

That I don't understand - thank you for any hints/guidance/explanations/ideas/suggestions etc!




More information about the Python-list mailing list