列表的标准偏差 [英] Standard deviation of a list

查看:89
本文介绍了列表的标准偏差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到几个(Z)列表的第一,第二,...个数字的均值和标准差.例如,我有

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,3.7,2.6,5,3.4]
C_Rank=[1.2,3.4,0.5,0.1,2.5,6.1]
# etc (up to Z_rank )...

现在,我要获取*_Rank[0]的均值和std,*_Rank[1]的均值和std,等等.
(即:所有(A..Z)_rank列表中第一个数字的均值和标准差;
所有(A..Z)_rank列表中第二个数字的均值和标准差;
第三位数的均值和标准差...;等等).

Now I want to take the mean and std of *_Rank[0], the mean and std of *_Rank[1], etc.
(ie: mean and std of the 1st digit from all the (A..Z)_rank lists;
the mean and std of the 2nd digit from all the (A..Z)_rank lists;
the mean and std of the 3rd digit...; etc).

推荐答案

自Python 3.4起/ PEP450 在标准库中有一个 statistics module ,该文件具有方法stdev ,用于计算像您这样的迭代器:

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

这篇关于列表的标准偏差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆