Shouldn't the coefficient be coeff = 1.0 / math.pi * math.sqrt(2.0 * math.pi) + eps In equation of normal equation the pi is outside of sqrt