By the law of large numbers, given a continuous random vector $\mathbf{x}$, then:
$$ \mathbb{E}[\mathbf{x}] \approx \frac{1}{N} \sum_{i=1}^{N} \mathbf{x}_i $$
Where $\mathbf{x}_1,\mathbf{x}_2,...,\mathbf{x}_N$ are sampled from $p(\mathbf{x})$. By the law of the unconscious statistician:
$$ \mathbb{E}[f(\mathbf{x})] \approx \frac{1}{N} \sum_{i=1}^{N} f(\mathbf{x}_i) $$
Now let $\theta$ be a vector of non-random parameters, such that $g(\mathbf{x};\theta)$ is some function of the random vector $\mathbf{x}$ and the parameters in $\theta$. Can I then approximate the following expectation:
$$ \mathbb{E}\left[\frac{\partial g(\mathbf{x};\theta)}{\partial \theta}\right] $$
Like this?
$$ \mathbb{E}\left[\frac{\partial g(\mathbf{x};\theta)}{\partial \theta}\right] \approx \frac{1}{N} \sum_{i=1}^{N} \frac{\partial g(\mathbf{x}_i;\theta)}{\partial \theta} $$
If I can, then is it accurate to say that:
$$ \mathbb{E}\left[\frac{\partial g(\mathbf{x};\theta)}{\partial \theta}\right] \approx \frac{\partial}{\partial \theta}\left(\frac{1}{N} \sum_{i=1}^{N} g(\mathbf{x}_i;\theta)\right) $$
In other words, the sample mean of a gradient is equal to the gradient of the sample mean?