Create a function called standarddeviation that takes a list

Create a function called standard_deviation that takes a list of numbers of inputs, computes the standard deviation and then returns the result. You may need to import math for this problem

This code has to be able to work with any list of numbers, and the list can be any length.

the picture is how the output should look.

Solution

from math import sqrt

def standard_deviation(vec):

n=len(vec)

avg=0.0

total=0.0

for i in range(n):

total=total+vec[i]

avg=total/n

var_total=0.0

for i in range(n):

var_total=var_total+((avg-vec[i])*(avg-vec[i]))

var=var_total/n

sd=sqrt(var)

print \'S.D : \',sd

Create a function called standard_deviation that takes a list of numbers of inputs, computes the standard deviation and then returns the result. You may need to

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site