gradient working with ranodomized theta and with l2 regularization