Mô -đun thống kê trong Python cung cấp một hàm được gọi là stdev (), có thể được sử dụng để tính độ lệch chuẩn. Chức năng stdev () chỉ tính toán độ lệch chuẩn từ một mẫu dữ liệu, thay vì toàn bộ dân số. & NBSP;stdev() , which can be used to calculate the standard deviation. stdev() function only calculates standard deviation from a sample of data, rather than an entire population.
Để tính toán độ lệch chuẩn của toàn bộ dân số, một hàm khác được gọi là pstdev () được sử dụng. & Nbsp;pstdev() is used.
Độ lệch chuẩn là một thước đo của sự lây lan trong thống kê. Nó được sử dụng để định lượng thước đo của sự lan truyền, biến thể của một tập hợp các giá trị dữ liệu. Nó rất giống với phương sai, đưa ra thước đo độ lệch trong khi phương sai cung cấp giá trị bình phương. Bộ được trải ra ngoài giá trị trung bình trung bình của chúng. Một thuộc tính hữu ích của độ lệch chuẩn là, không giống như phương sai, nó được biểu thị bằng cùng một đơn vị với dữ liệu. & NBSP; is a measure of spread in Statistics. It is used to
quantify the measure of spread, variation of a set of data values. It is very much similar to variance, gives the measure of deviation whereas variance provides the squared value.
A low measure of Standard Deviation indicates that the data are less spread out, whereas a high value of Standard Deviation shows that the data in a set are spread apart from their mean average values. A useful property of the standard deviation is that, unlike the variance, it is expressed in the same units
as the data.
Cú pháp: Stdev ([Data-Set], Xbar) tham số: & nbsp; [Data]: Một số có thể có số có giá trị thực. Độ lệch của các giá trị được truyền dưới dạng tham số. Exexceptions: & nbsp; StatisticerError được nâng lên cho dữ liệu-set nhỏ hơn 2 giá trị được truyền dưới dạng tham số. -Set. & nbsp; & nbsp; stdev( [data-set], xbar )
Parameters :
[data] : An iterable with real valued numbers.
xbar (Optional): Takes actual mean of data-set as value.
Returnype : Returns the actual standard deviation of the values passed as parameter.
Exceptions :
StatisticsError is raised for data-set less than 2 values passed as parameter.
Impossible/precision-less values when the value provided as xbar doesn’t match actual mean of the data-set.
Mã số 1: & nbsp; & nbsp;
Python3
import statistics
sample = Standard Deviation of the sample is 1.5811388300841898 0Standard Deviation of the sample is 1.5811388300841898 1Standard Deviation of the sample is 1.5811388300841898 2Standard Deviation of the sample is 1.5811388300841898 3Standard Deviation of the sample is 1.5811388300841898 2Standard Deviation of the sample is 1.5811388300841898 5__12
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725251The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725252The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725253
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725254The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725255 The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725256
Đầu ra: & nbsp;
Standard Deviation of the sample is 1.5811388300841898Mã số 2: Trình diễn stdev () trên một tập hợp các loại dữ liệu khác nhau & nbsp; & nbsp; Demonstrate stdev() on a varying set of data types
Python3
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725257 The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725258import Standard Deviation of the sample is 1.5811388300841898 Variance of the sample is 2.50
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725257 Standard Deviation of the sample is 1.5811388300841898 Variance of the sample is 2.52import Standard Deviation of the sample is 1.5811388300841898 Variance of the sample is 2.54
Standard Deviation of the sample is 1.5811388300841898 Variance of the sample is 2.55= The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.4196784483387252522____11Standard Deviation of the sample is 1.5811388300841898 2Standard Deviation of the sample is 1.5811388300841898 3Standard Deviation of the sample is 1.5811388300841898 2Standard Deviation of the sample is 1.5811388300841898 9Standard Deviation of the sample is 1.5811388300841898 2
Các
Các
=5= The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725252=8Standard Deviation of the sample is 1.5811388300841898 2Standard Deviation of the sample is 1.5811388300841898 00Standard Deviation of the sample is 1.5811388300841898 2
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725251The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725252Standard Deviation of the sample is 1.5811388300841898 10
Standard Deviation of the sample is 1.5811388300841898 11The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725255Standard Deviation of the sample is 1.5811388300841898 13
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725251The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725252Standard Deviation of the sample is 1.5811388300841898 16
Standard Deviation of the sample is 1.5811388300841898 11The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725255Standard Deviation of the sample is 1.5811388300841898 19
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725251The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725252Standard Deviation of the sample is 1.5811388300841898 22
Standard Deviation of the sample is 1.5811388300841898 11The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725255Standard Deviation of the sample is 1.5811388300841898 25
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725251The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725252Standard Deviation of the sample is 1.5811388300841898 28
Standard Deviation of the sample is 1.5811388300841898 11The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725255Standard Deviation of the sample is 1.5811388300841898 31
Đầu ra: & nbsp;
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.41967844833872525Mã số 2: Trình diễn stdev () trên một tập hợp các loại dữ liệu khác nhau & nbsp; & nbsp;Demonstrate the difference between results of variance() and stdev()
Python3
import statistics
sample = Standard Deviation of the sample is 1.5811388300841898 0Standard Deviation of the sample is 1.5811388300841898 1Standard Deviation of the sample is 1.5811388300841898 2Standard Deviation of the sample is 1.5811388300841898 3Standard Deviation of the sample is 1.5811388300841898 2Standard Deviation of the sample is 1.5811388300841898 5__12
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725251The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725252Standard Deviation of the sample is 1.5811388300841898 49
Standard Deviation of the sample is 1.5811388300841898 50The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725255The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725256
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725251The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725252Standard Deviation of the sample is 1.5811388300841898 55
Standard Deviation of the sample is 1.5811388300841898 56The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725255Standard Deviation of the sample is 1.5811388300841898 58
Đầu ra: & nbsp;
Standard Deviation of the sample is 1.5811388300841898 Variance of the sample is 2.5Mã số 2: Trình diễn stdev () trên một tập hợp các loại dữ liệu khác nhau & nbsp; & nbsp; Demonstrate the use of xbar parameter
Python3
import statistics
sample = Standard Deviation of the sample is 1.5811388300841898 0Standard Deviation of the sample is 1.5811388300841898 1Standard Deviation of the sample is 1.5811388300841898 2Standard Deviation of the sample is 1.5811388300841898 3Standard Deviation of the sample is 1.5811388300841898 2Standard Deviation of the sample is 1.5811388300841898 5__12
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725254The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725255 The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725256
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725251The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725252Standard Deviation of the sample is 1.5811388300841898 81
Đầu ra: & nbsp;
Đầu ra: & nbsp;
Standard Deviation of Sample set is 0.6047037842337906Mã số 2: Trình diễn stdev () trên một tập hợp các loại dữ liệu khác nhau & nbsp; & nbsp; Demonstrates StatisticsError
Python3
import statistics
sample = Standard Deviation of the sample is 1.5811388300841898 0Standard Deviation of the sample is 1.5811388300841898 1Standard Deviation of the sample is 1.5811388300841898 2Standard Deviation of the sample is 1.5811388300841898 3Standard Deviation of the sample is 1.5811388300841898 2Standard Deviation of the sample is 1.5811388300841898 5__12
The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725251Standard Deviation of the sample is 1.5811388300841898 95
Đầu ra: & nbsp;
Traceback (most recent call last): File "/home/f921f9269b061f1cc4e5fc74abf6ce10.py", line 12, in print(statistics.stdev(sample)) File "/usr/lib/python3.5/statistics.py", line 617, in stdev var = variance(data, xbar) File "/usr/lib/python3.5/statistics.py", line 555, in variance raise StatisticsError('variance requires at least two data points') statistics.StatisticsError: variance requires at least two data pointsMã số 2: Trình diễn stdev () trên một tập hợp các loại dữ liệu khác nhau & nbsp; & nbsp;
- The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725257 The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725258import Standard Deviation of the sample is 1.5811388300841898 Variance of the sample is 2.50
- The Standard Deviation of Sample1 is 3.9761191895520196 The Standard Deviation of Sample2 is 1.8708286933869707 The Standard Deviation of Sample3 is 7.8182478855559445 The Standard Deviation of Sample4 is 0.419678448338725257 Standard Deviation of the sample is 1.5811388300841898 Variance of the sample is 2.52import Standard Deviation of the sample is 1.5811388300841898 Variance of the sample is 2.54