Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python statistics.stdev() Method

Python statistics.stdev() Method

Python statistics Module Python statistics Module

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:

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

)

print

(

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 Python statistics Module