Applying stdev & pstdev Functions of statistics Module in Python (2 Examples)
This post illustrates how to apply the stdev and pstdev functions in the Python programming language.
Creation of Exemplifying Data
x = [1, 3, 3, 7, 1, 3, 5, 1, 2, 2, 1, 2, 1, 3, 1, 7] # Constructing a list in Python print(x) # Displaying the example list # [1, 3, 3, 7, 1, 3, 5, 1, 2, 2, 1, 2, 1, 3, 1, 7] |
x = [1, 3, 3, 7, 1, 3, 5, 1, 2, 2, 1, 2, 1, 3, 1, 7] # Constructing a list in Python print(x) # Displaying the example list # [1, 3, 3, 7, 1, 3, 5, 1, 2, 2, 1, 2, 1, 3, 1, 7]
Example 1: How to Apply the stdev() Function of the statistics Module to Calculate the Sample Standard Deviation
import statistics # Load statistics |
import statistics # Load statistics
print(statistics.stdev(x)) # Sample Standard Deviation # 2.023816526598529 |
print(statistics.stdev(x)) # Sample Standard Deviation # 2.023816526598529
Example 2: How to Apply the pstdev() Function of the statistics Module to Calculate the Population Standard Deviation
print(statistics.pstdev(x)) # Population Standard Deviation # 1.9595519258238603 |
print(statistics.pstdev(x)) # Population Standard Deviation # 1.9595519258238603