title: Python: Calculating the inverse of a pseudo inverse matrix
body: <p>I am trying to calculate the pseudo inverse of a matrix which should be not very difficult. The problem is inverting the matrix.</p>
  
  <p>I am using the following code:</p>
  
  <pre><code>A=numpy.random.random_sample((4,5,))
  A=mat(A)
  B=pseudoinverse(A)
  
  def pseudoinverse(A):
      helper=A.T*A
      print helper*helper.I
      PI=helper.I*A.T
      return PI`
  </code></pre>
  
  <p>to test this I included the print line. helper*helper.I should give unity. The output I get from this is:</p>
  
  <pre><code> [[ 2.    -1.     0.     0.     3.   ]
  
   [ 0.     2.     0.     0.     3.5  ]
  
   [ 0.    -0.5    1.125 -1.     2.25 ]
  
   [ 2.     0.     0.25  -2.     3.   ]
  
   [ 0.     0.     0.5   -2.     4.   ]]
  </code></pre>
  
  <p>which is clearly not unity. I don't know what I did wrong and really would like to know.</p>