title: Why is inverting a positive definite matrix via Cholesky decomposition slower than regular inversion with numpy?
body: <p>It's mathematically known that inverting a positive definite matrix via Cholesky decomposition is faster than just using <code>np.linalg.inv(X)</code>. However, when I experimented with both and it turns out Cholesky decomposition's performance is worse!</p>
  
  <pre><code># Inversion through Cholesky
  p = X.shape[0]
  Ip = np.eye(p)
  %timeit scipy.linalg.cho_solve(scipy.linalg.cho_factor(X,lower=True), Ip)
  
  The slowest run took 17.96 times longer than the fastest. This could mean that an intermediate result is being cached.
  10000 loops, best of 3: 107 µs per loop
  
  
  # Simple inversion
  %timeit np.linalg.inv(X)
  
  The slowest run took 58.81 times longer than the fastest. This could mean that an intermediate result is being cached.
  10000 loops, best of 3: 25.9 µs per loop
  </code></pre>
  
  <p>The latter took shorter. Why is this? In <code>R</code>, <code>chol2inv(chol(X))</code> is usually faster than <code>solve(X)</code>.</p>