Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

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 )...

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).

1 Answer

0 votes
by (106k points)

Since the release of Python 3.4 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)

Output:- 

2.0634114147853952

To know more about this you can have a look at the following video tutorial:-

Related questions

Browse Categories

...