code: def gradfunc(self, p):
          
          self._set_stochastics(p)
          for i in xrange(self.len):
              self.grad[i] = self.diff(i)
  
          return -1 * self.grad
docs: The gradient-computing function that gets passed to the optimizers,
          if needed.