user1972847
user1972847

Reputation: 33

Python multiplication Matrix with Matrix transpose with array

[1]: https://upload.wikimedia.org/math/3/0/a/30aed0153521807d5a314ea76f37e723.png [1].

I want to write the above equation in Python using numpy functions:

b = b - INV(J'*J) * J' * r(b)

J is matrix , J' the matrix transpose of J, X and r arrays

b = b  - linalg.inv((zip(*J)).dot(J)).dot(zip(*J)).dot(r)

this is not working... any suggestion?

EDIT

error:

AttributeError: 'zip' object has no attribute 'dot'

,... I use Python 3.2

Upvotes: 0

Views: 2293

Answers (1)

SethMMorton
SethMMorton

Reputation: 48735

I'm assuming you are using zip because other posts about how to transpose a list of lists in python recommend using this. This is not what you are using... you are using numpy, so you want to use the .T attribute which returns the transpose of your array. Additionally, dot is a numpy function, not a method of a nmpy array:

b = b - np.dot(np.dot(linalg.inv(np.dot(J.T, J)), J.T), r(b))

Upvotes: 1

Related Questions