Python statistics.stdev() Method
Python statistics.stdev() Used to compute the sample standard deviation of a given data set.
Syntax
The syntax of the statistics.stdev() method is as follows:
statistics.stdev(data, xbar=None)
Parameter Description:
- data -- an iterable containing numeric values, such as a list or tuple.
- xbar -- an optional parameter indicating the mean of the data set; if not provided, the function computes the mean internally.
Return Value
The function computes and returns the sample standard deviation from the given data set as the result.
Example
The following example demonstrates the stdev() function:
Example
import
statistics
data
=
[
1
,
2
,
3
,
4
,
5
]
stdev
=
statistics.
stdev
(
data
)
(
stdev
)
Output result:
1.5811388300841898
In the above example, the given data set is [1, 2, 3, 4, 5], and the stdev() method computes a sample standard deviation of 1.5811388300841898.
The sample standard deviation is a statistic measuring the dispersion of a data set, indicating how far data values deviate from the mean. It is the square root of the variance and is used to describe how spread out the data is.
Unlike the pstdev() method, the stdev() method computes the sample standard deviation rather than the population standard deviation, so it uses an unbiased estimate. If you have data for the entire population, you can use the pstdev() method to compute the population standard deviation.
Python statistics Module