modified estimate_K.py to solve beta and lambda