The gradient-computing function that gets passed to the optimizers,
        if needed.

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

        return -1 * self.grad