def nb_r_deriv(r, data_row):
n = len(data_row)<EOL>d = sum(digamma(data_row + r)) - n*digamma(r) + n*np.log(r/(r+np.mean(data_row)))<EOL>return d<EOL>
Derivative of log-likelihood wrt r (formula from wikipedia)

Args:
    r (float): the R paramemter in the NB distribution
    data_row (array): 1d array of length cells