I am working on replicating a paper titled “Improving Mean Variance Optimization through Sparse Hedging Restriction”. The authors’ idea is to use Graphical Lasso algorithm to infuse some bias in the estimation process of the inverse of the sample covariance matrix. The graphical lasso algorithm works perfectly fine in R, but when I use python on the same data with the same parameters I get two sorts of errors:

1- If I use coordinate descent (cd ) mode as a solver, I get a floating point error saying that: the matrix is not symmetric positive definite and that the system is too ill-conditioned for this solver. “

**FloatingPointError**: Non SPD result: the system is too ill-conditioned for this solver. The system is too ill-conditioned for this solver” (The thing that bugs me is that I tried this solver on a simulated Positive definite matrix and It game me this error)

2- If I use the Least Angle Regression (LARS) mode (Which is less stable but recommended for ill-conditioned matrices) I get an Overflow error stating that the integer is too large to be converted to a float “

**OverflowError**: int too large to convert to float”

To my knowledge, unlike C++ and other languages, python is not restricted by an upper maximum for integer numbers (besides the capacity of the machine itself). Whereas the floats are restricted. I think this might be the source of the later problem. (I have also heard in the past that R is much more robust in terms of dealing ill-conditioned matrices). I would be glad to hear you experiences with graph lasso in R or python.

With this email, I have attached a little python code that simulates this problem in a few lines. Any input will be of great appreciation.

Thank you all,

Code:

```
from sklearn.covariance import graph_lasso
from sklearn.datasets import make_spd_matrix
symetric_PD_mx= make_spd_matrix(100)
glout = graph_lasso(emp_cov=symetric_PD_mx, alpha=0.01,mode="lars")
```