When will numpy.linalg.inv() and numpy.linalg.pinv() give very different values?
Asked Answered
S

1

0

for the equation Ax = b, let A = USV.t, i need to calculate inverse of (S.T@S). I noticecd that using np.linalg.inv() and np.linalg.pinv() gives extremely different results. np.allclose() infact returns false.

I want to know why this is happening, any mathematical insight? maybe due to some property of A? here A is a non-linear function of a dynamic time series.

Basically when can you expect pinv() and inv() to give very different results?

Subsidize answered 2/4, 2022 at 18:1 Comment(2)
you should provide an example of such matrix.Haema
matrix of activations, as a function, f(x,u,w), previous activation, input, and reservoir weights. cant really provide example it will be too big.Subsidize
S
0

kind of figured it out. np.linalg.pinv, works by SVD decomposition and if A = USVt then pinv(A) = V S^-1 Ut, and the shape of U and V are changed such that S^-1 is either mxm or nxn matrix. also, there is a cutoff for singular values, where less than cutoff are treated as zero. so if there are many small singular values, many rows/columns of V/U will be ignored and as such inv() and pinv() will give significantly different results.

Subsidize answered 6/4, 2022 at 9:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.