error in k_estimate

Still have problems in convergence loop. Looping always stop if covmat
has inf value.

Suggestion: Give a try-catch to stop the loop if  covmat has inf.