Implementation : Added routine to compute the sample variance of the gradient