Standard Deviation σ
destination source:https://www.plus2net.com/python/math-standard-deviation.php
Standard Deviation σ
- Find out the average value (μ ) of the numbers or the list
- Find out the sum (Σ) of square of difference between number and average value
- Divide the sum by number of elements ( N )
- Take the square root of the above division
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
Related Article
destination source:https://www.plus2net.com/python/math-standard-deviation.php