How do I create a normal distribution in pytorch?
I want to create a random normal distribution with a given mean and std.

You can easily use torch.Tensor.normal_() method.

Let's create a matrix Z (a 1d tensor) of dimension 1 × 5, filled with random elements samples from the normal distribution parameterized by mean = 4 and std = 0.5.

torch.empty(5).normal_(mean=4,std=0.5)


Result:

tensor([4.1450, 4.0104, 4.0228, 4.4689, 3.7810])

