# Use of Weighting Matrix (GMM)

While conducting estimation via the Generalised Method of Moments, or GMM, I understand that we need to minimise the following expression:

$$Q_n(\theta)=g_n(\theta)'W_ng_n(\theta)$$

Where $$g_n(\theta)$$ is a vector of sample moments, $$W_n$$ is the weighting matrix, and of course, $$\theta$$ is our parameter of interest. I have also been told that the optimal weighting matrix is the inverse of the covariance of the sample moments. I do not understand the reason for this.