Variational theorem for the generalized diffusion matrix