arrays - Standard Deviation for row in table python -


What I'm trying to do is calculate the standard deviation of each line in the table row, everything is imaginable Have tried to execute it correctly, but it has not received it.

The array looks like this

  array = [[4, 6, 1, -3, -12], [9, 14, -4, 32, 0 ], [3, 12, -2, 8], [4, 4, 4, 4, 4]]   

Python Code:

  array From file import array to row: mean = sum (line) / lane (line) print ("STD dev =", (amount x (x-mean) ** 2.0 for x in line) / float (lane STD Dev = 12.6237870704476 STD Dev = 9.286549412 99512 STD Dev = 0.0    STD Dev = 6.368673331236263 STD Dev = 12.6237870704476 STD Dev = 9.286549412 99512 STD Dev = 0.0 < / Code>   

Already like this To get the standard deviation of each line of the array which it does this: [16] In: [16] Import as NP: array = [[4, 6, 1, -3, -12], [10, 14, -4, 32, 0], [22, -3, 10, -2, 8], [3, 4, 4, 4, 2]] [18]: Np.array (array) .std (1) out [18]: array ([6.37, 12.61, 9.12, 0.8]) By chance, if we have Np.array (Array) .std (0) , we will get the standard deviation of each column.

without numpy

with Python 3 and an imported module:

  array = [[4, 6, 1, -3, -12], [10, 14, -4, 32, 0], [22, 3 = 10, -2, 8], [3, 4, 4, 4, 2]] row in array For: = zodiac sign / line (line) print ("STD dev =", (sum (x-mid) ** 2.0 for x in line) / float (line (line)) ** 0.5 )   

This produces the output:

  STD dev = 6.368673331236263 STD dev = 12.611106216347558 ​​STD dev = 9.121403400793104 STD dev = 0.8   

optional formula Based on the circumstances, the formula for standard deviation is either in AI or n or n-1 in the place where N The number of data points is the solution using the above calculation n n-1 :
  array = [ [4, 6, 1, -3, -12], [9, 14, -4, 32, 0] for line in array, [22, -3, 12, -2, 8], [4, 4] , 4, 4, 4]] Mean = sum (row) / len (line) print ("STD dev =", (z = 2.0) for x in line 2.0) / float (line (line) -1)) ** 0.5)   

This equation The result is:

  STD dev = 7.120393247567159 ST DEV = 14.11382301150188 STD dev = 10.382677881933928 STD dev = 0.0    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -