-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunction_practice.py
More file actions
43 lines (32 loc) · 929 Bytes
/
Copy pathfunction_practice.py
File metadata and controls
43 lines (32 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import math
def return_sum(x,y):
c = x + y
return c
# res = return_sum(4,5)
# print(res)
n = [94,61,93,154,78,65,32]
def get_mean(sample):
mean = sum(sample) / len(sample)
return mean
avg = get_mean(n)
def diff_from_mean(mean: int, observations: list) -> list:
differences = []
for x in observations:
difference = mean - x
differences.append(difference)
return differences
y = diff_from_mean(avg, n)
def observations_squared(distances_from_mean: list) -> list:
squared = []
for x in distances_from_mean:
sq = x ** 2
squared.append(sq)
sum_of_sq = sum(squared)
return sum_of_sq
z = observations_squared(y)
def get_the_variance(sq_sum,count):
variance = sq_sum / count
return variance
v = get_the_variance(z,len(n))
stdev = math.sqrt(v)
print("The standard deviation of the list is: " + str(stdev) + ", while the mean is: " + str(avg))