Tools and Techniques: Orthogonal Projections and Their Applications

Dear QuantEcon Team,

My comment refers to https://lectures.quantecon.org/py/orth_proj.html - the site on “Tools and Techniques: Orthogonal Projections and Their Applications”.

Your solution to Ex. 3 should be slightly tweaked, in my opinion: in order to use n, k = X.shape in the set-up, X ought to be an array. However, you declare X = [[1, 0], [0, -6], [2, 2]] further down in the solutions. It should be X = np.array([ [1, 0], [0, -6], [2, 2] ]) instead for the code to work well, I believe. Please, correct me if I missed anything.

Cheers!

Moreover, we could add some line such as if isinstance(X,np.ndarray) == True:, and so on.

Best!

Hi Lorenzo,

Thanks for your comment.

You’re correct that X should be an array. The list comprehension following the X and y appears to convert them to arrays.

X, y = [np.asarray(z) for z in (X, y)]

I think this has been done because it is easier to interpret X and y when written as a Python list, however it is perfectly valid to simply write X as a numpy array to begin with.

A check of the type of X is a good idea, but is probably unnecessary for the suggested solution in the lecture. If you were writing a package that would be useful!

Yes,

X, y = [np.asarray(z) for z in (X, y)]

converts X to an array, along with y.

Thanks for your thoughts @lorenzopautasso, they’re appreciated.

Sorry @john.stachurski, missed that one upon reading. Keep up the great work!