statistics.pstdev(data, mu = None)
The statistics.pstdev function returns the standard deviation of the population composed of the elements in data.
- data: Iterable for whose elements you want to obtain the standard deviation.
- mu: Optional argument. Value from which deviations are calculated. If omitted, they are obtained with respect to the mean value of the data.
The statistics.pstdev function returns a real number.
We can obtain the standard deviation of the values of a list with the following code:
In this second example we are going to generate a list made up of a thousand random values extracted from a Gaussian distribution with mean 5 and standard deviation 1:
Let's show the histogram:
plt.hist(y, bins = 10)
plt.grid()
plt.show()
Let's get its standard deviation below:
If we specify the value 10 as mu argument, the deviations will be calculated with respect to this value: