Sample from Mixture Density

I am trying to sample from a mixture density:

import torch
from torch.distributions.mixture_same_family import MixtureSameFamily
from torch.distributions.categorical import Categorical
from torch.distributions.normal import Normal

# Set values for the mixture
alphas = [0.6, 0.3, 0.1]
means = [30, 60, 120]
sigmas = [5, 3, 1]

gm = MixtureSameFamily(mixture_distribution=Categorical(probs=torch.tensor(alphas)),
                       component_distribution=Normal(loc=torch.tensor(means), scale=torch.tensor(sigmas)))

# Draw 1e5 random samples from the mixture distribution
torch.manual_seed(seed=42)
samples = gm.sample(sample_shape=torch.Size([100]))

But I am getting this error:

Traceback (most recent call last):
  File "mdn_test.py", line 27, in <module>
    samples = gm.sample(sample_shape=torch.Size([100]))
  File "/data/miniconda3/envs/py38/lib/python3.8/site-packages/torch/distributions/mixture_same_family.py", line 167, in sample
    comp_samples = self.component_distribution.sample(sample_shape)
  File "/data/miniconda3/envs/py38/lib/python3.8/site-packages/torch/distributions/normal.py", line 64, in sample
    return torch.normal(self.loc.expand(shape), self.scale.expand(shape))
RuntimeError: "normal_kernel_cpu" not implemented for 'Long'

Please help - I am not able to understand what this error means.
Regards,
Indrajit

Pass the means and sigmas as floating point values:

means = [30., 60., 120.]
sigmas = [5., 3., 1.]

and it should work.

Awesome! Thank you so much!