fix a numerical instability bug with negative feature values