The gauss
method is used to get a floating value chosen from a Gaussian or normal distribution with the given mean and standard deviation.
The Gaussian distribution, also known as the normal distribution, is a symmetric probability distribution centered on the mean, indicating that data near the mean occur more frequently than data far from it. The normal distribution will appear as a bell curve on a graph. The following image shows what a bell curve looks like when plotted on a graph.
random.gauss(mu, sigma)
mu
: The mean value.sigma
: The standard deviation value.This method returns a floating-point value.
Let's look at the code below:
import randommu = 5sigma = 3.4val = random.gauss(mu, sigma=sigma)print("random.gauss(%s, %s) = %s" % (mu, sigma, val))
random
module.mu
.sigma
.gauss(mu,sigma)
in the variable val
.val
to the console.