# Creating a Multivariate Normal Distribution with multiple centers and sampling from them

Hi all, I’m wondering how I could create a 2D Gaussian distribution, where we have multiple centers, and sample from it? I tried the code below, but whenever I tried to sample a batch, I would get samples from every center. What I actually want is to first create these multiple centers, then re-normalize the distributions such that overlapping regions would have higher probability. Then sample a batch of points out based on this.

``````centers = torch.tensor([[0.1, 0.1],
[0.9, 0.9],
[0.5, 0.5],
[0.9, 0.1],
[0.1, 0.9]])

mv = torch.distributions.multivariate_normal.MultivariateNormal(centers, torch.eye(2))
``````

Hi Legoh!

If I understand what you want correctly, you have a multigaussian distribution.
That is, your probability distribution is the sum of multiple gaussian distributions
(as distinct from a single random variate being a sum of multiple gaussian
variates).

In your example, it looks like you have five “centers.” Build a gaussian
distribution for each of your five centers, generate a random integer from
0 to 4 (e.g., `torch.multinomial()`) and use that to choose which of your
five gaussian distributions to sample from. If appropriate, you can weight