Use torch.distributions.Normal
torch.manual_seed(10)

mu = torch.randn(1)
sigma = torch.rand(1)

z = torch.distributions.Normal(mu, sigma)

z.log_prob(torch.Tensor([1.]))

Output is:

tensor([-27.3894])

Use torch.distributions.MultivariateNormal
torch.manual_seed(10)

mu = torch.randn(1)
sigma = torch.rand(1)

z = torch.distributions.MultivariateNormal(mu, covariance_matrix=torch.diagflat(sigma))

z.log_prob(torch.Tensor([1.]))

Output is:

tensor(-6.1411)

I expected to get the same result for both cases. What’s wrong?