Standard deviation of a list

后端 未结 8 1735
旧时难觅i
旧时难觅i 2020-12-07 09:57

I want to find mean and standard deviation of 1st, 2nd,... digits of several (Z) lists. For example, I have

A_rank=[0.8,0.4,1.2,3.7,2.6,5.8]
B_rank=[0.1,2.8,         


        
8条回答
  •  悲&欢浪女
    2020-12-07 09:58

    Since Python 3.4 / PEP450 there is a statistics module in the standard library, which has a method stdev for calculating the standard deviation of iterables like yours:

    >>> A_rank = [0.8, 0.4, 1.2, 3.7, 2.6, 5.8]
    >>> import statistics
    >>> statistics.stdev(A_rank)
    2.0634114147853952
    

提交回复
热议问题