-2

I have three feature vectors as :

A = [1,0,1,0,0,0]
B = [0,0,0,1,1,1]
C = [1,1,1,0,1,0]

Is there a python library that can help me compute the std dev of these ?

Rakesh Sharma
  • 301
  • 1
  • 3
  • 11
  • 1
    Well in case if you want to stick to Pure Python and you can use Python 3.4+ then can try the [statistics](https://docs.python.org/3/library/statistics.html) module from the standard library. – Ashwini Chaudhary Nov 01 '14 at 21:35

2 Answers2

1
>>> A = [1,0,1,0,0,0]
>>> B = [0,0,0,1,1,1]
>>> C = [1,1,1,0,1,0]
>>> numpy.std(map(numpy.mean,zip(A,B,C)))
0.16666666666666666
>>> map(numpy.mean,zip(A,B,C))
[0.66666666666666663, 0.33333333333333331, 0.66666666666666663, 0.33333333333333331, 0.66666666666666663, 0.33333333333333331]
Maria Zverina
  • 10,863
  • 3
  • 44
  • 61
1

You can use numpy.std for population standard deviation:

>>> [numpy.std(arr) for arr in (A, B, C)]
[0.47140452079103168, 0.5, 0.47140452079103168]

However, if you want to stick to built-in modules (and have Python v3.4+), you could check out the functions pstdev and stdev in the statistics module to calcultae population standard deviation and sample standard deviation respectively.

anon582847382
  • 19,907
  • 5
  • 54
  • 57