logistic regression mathematical derivation