Math functions for Logistic Regression - untested