list - Math Domain Error with Standard Deviation -


I am having trouble calculating the standard deviation in the table (list of lists). I am able to get 'population' standard deviation, but when I try to divide by n-1 for sample standard deviation, I get a math domain error. # Line standard deviation (ROWS) for i for the range: total = 0 average = 0 sum2 = 0 sum3 = 0 stdDev = 0 in the range J (COLUMNS): total = float (total + array [i] [j]) Avg = total / len (array [0]) sum2 = sum2 + (array [i] [j]) ** 2 stdDev = sqrt ((sum2 / (line array [0]) - (average * average)) print (StdDev) You are taking the square root of a negative number, which is Mathematics can not handle .

  & gt; & Gt; & Gt; Math.sqrt (-1) Traceback (most recent call final): File "& lt; stdin>", line 1, & lt; Module & gt; Value error: math domain error    

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? -