Hướng dẫn standard deviation filter python - Python bộ lọc độ lệch chuẩn

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. 

Show

    Để 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. 

    Standard Deviation is calculated by :
    
    

    where x1, x2, x3.....xn are observed values in sample data,

    is the mean value of observations and N is the number of sample observations.

    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 
    0
    Standard Deviation of the sample is 1.5811388300841898 
    1
    Standard Deviation of the sample is 1.5811388300841898 
    2
    Standard Deviation of the sample is 1.5811388300841898 
    3
    Standard Deviation of the sample is 1.5811388300841898 
    2
    Standard 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.41967844833872525
    1
    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.41967844833872525
    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.41967844833872525
    3

    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.41967844833872525
    4
    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.41967844833872525
    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.41967844833872525
    6

    Đầu ra: & nbsp; 

    Standard Deviation of the sample is 1.5811388300841898 

    Mã 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.41967844833872525
    7
    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.41967844833872525
    8import
    Standard Deviation of the sample is 1.5811388300841898 
    Variance of the sample is 2.5
    0

    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.41967844833872525
    7
    Standard Deviation of the sample is 1.5811388300841898 
    Variance of the sample is 2.5
    2import
    Standard Deviation of the sample is 1.5811388300841898 
    Variance of the sample is 2.5
    4

    Standard Deviation of the sample is 1.5811388300841898 
    Variance of the sample is 2.5
    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.41967844833872525
    22____11
    Standard Deviation of the sample is 1.5811388300841898 
    2
    Standard Deviation of the sample is 1.5811388300841898 
    3
    Standard Deviation of the sample is 1.5811388300841898 
    2
    Standard Deviation of the sample is 1.5811388300841898 
    9
    Standard 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.41967844833872525
    2=8
    Standard Deviation of the sample is 1.5811388300841898 
    2
    Standard Deviation of the sample is 1.5811388300841898 
    00
    Standard 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.41967844833872525
    1
    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.41967844833872525
    2
    Standard Deviation of the sample is 1.5811388300841898 
    10

    Standard Deviation of the sample is 1.5811388300841898 
    11
    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.41967844833872525
    5
    Standard 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.41967844833872525
    1
    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.41967844833872525
    2
    Standard Deviation of the sample is 1.5811388300841898 
    16

    Standard Deviation of the sample is 1.5811388300841898 
    11
    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.41967844833872525
    5
    Standard 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.41967844833872525
    1
    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.41967844833872525
    2
    Standard Deviation of the sample is 1.5811388300841898 
    22

    Standard Deviation of the sample is 1.5811388300841898 
    11
    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.41967844833872525
    5
    Standard 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.41967844833872525
    1
    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.41967844833872525
    2
    Standard Deviation of the sample is 1.5811388300841898 
    28

    Standard Deviation of the sample is 1.5811388300841898 
    11
    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.41967844833872525
    5
    Standard 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.41967844833872525

    Mã 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 
    0
    Standard Deviation of the sample is 1.5811388300841898 
    1
    Standard Deviation of the sample is 1.5811388300841898 
    2
    Standard Deviation of the sample is 1.5811388300841898 
    3
    Standard Deviation of the sample is 1.5811388300841898 
    2
    Standard 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.41967844833872525
    1
    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.41967844833872525
    2
    Standard Deviation of the sample is 1.5811388300841898 
    49

    Standard Deviation of the sample is 1.5811388300841898 
    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.41967844833872525
    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.41967844833872525
    6

    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.41967844833872525
    1
    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.41967844833872525
    2
    Standard Deviation of the sample is 1.5811388300841898 
    55

    Standard Deviation of the sample is 1.5811388300841898 
    56
    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.41967844833872525
    5
    Standard 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.5

    Mã 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 
    0
    Standard Deviation of the sample is 1.5811388300841898 
    1
    Standard Deviation of the sample is 1.5811388300841898 
    2
    Standard Deviation of the sample is 1.5811388300841898 
    3
    Standard Deviation of the sample is 1.5811388300841898 
    2
    Standard 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.41967844833872525
    4
    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.41967844833872525
    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.41967844833872525
    6

    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.41967844833872525
    1
    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.41967844833872525
    2
    Standard Deviation of the sample is 1.5811388300841898 
    81

    Đầu ra: & nbsp;

    Đầu ra: & nbsp; 

    Standard Deviation of Sample set is 0.6047037842337906

    Mã 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 
    0
    Standard Deviation of the sample is 1.5811388300841898 
    1
    Standard Deviation of the sample is 1.5811388300841898 
    2
    Standard Deviation of the sample is 1.5811388300841898 
    3
    Standard Deviation of the sample is 1.5811388300841898 
    2
    Standard 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.41967844833872525
    1
    Standard 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 points

    Mã 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.41967844833872525
      7
      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.41967844833872525
      8import
      Standard Deviation of the sample is 1.5811388300841898 
      Variance of the sample is 2.5
      0
    • 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.41967844833872525
      7
      Standard Deviation of the sample is 1.5811388300841898 
      Variance of the sample is 2.5
      2import
      Standard Deviation of the sample is 1.5811388300841898 
      Variance of the sample is 2.5
      4