# How to sample from a non-parametric density estimate?

I have a kernel based non-parametric distribution, let's assume it's a Normal kernel, but the variance of each component is different. How do I sample from this density? If all the components had the same variance, I could just sample the Normal (wich mean would be chosen) with the same probability, but I'm not sure if I can sample this way when the variance is different.

$$f(x) = \frac{1}{M}\sum^M_{i=1} \phi(x;\mu_i,\sigma^2_i),$$ where $\phi(x;\mu_i,\sigma^2_i)$ is the density of a Normal distribution with mean $\mu_i$ and variance $\sigma^2_i$ at $x$.

1. Pick $i$ uniformly from $\{1, \dots, M\}$.
2. Sample from $\mathcal{N}(\mu_i, \sigma_i)$.