Distributed linear and logistic regression