Standard Deviation σ


Standard Deviation

  1. Find out the average value (μ ) of the numbers or the list
  2. Find out the sum (Σ) of square of difference between number and average value
  3. Divide the sum by number of elements ( N )
  4. Take the square root of the above division
We will create a Python function to return the Standard Deviation.
import math
list1=[12,13,15,11,9]
def my_stddev(my_list):
    my_sum=0
    for i in my_list:
        my_sum=my_sum+i
    #print(my_sum)

    my_no=len(my_list)
    my_avg=my_sum/my_no
    sum_avg=0
    for i in my_list:
        sum_avg=sum_avg+math.pow((i-my_avg),2)
    std=math.sqrt(sum_avg/my_no)
    return std
  
print(my_stddev(list1))
Output
2.0


plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer