-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfuncom.py
66 lines (60 loc) · 1.48 KB
/
funcom.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# coding=utf-8
"""
@author: lizhen Created on 2019.8.6
"""
def rms(list):
"""
@author : Lizhen
Version : 1.0 Created 2019.08.06
Purpose : 计算列表的均方根误差
Input : list —— 待计算均方根的列表
Output : cal —— 列表的均方根
"""
from math import sqrt
cal = 0.0
for each in list:
cal += each * each
cal = sqrt(cal / len(list))
return cal
def std(list):
"""
@author : Lizhen
Version : 1.0 Created 2019.08.10
Purpose : 计算列表的标准差
Input : list —— 待计算标准差的列表
Output : cal —— 列表的标准差
"""
from math import sqrt
cal = 0.0
list_mean = mean(list)
for each in list:
cal += (each - list_mean) ** 2
cal = sqrt(cal / len(list))
return cal
def mean(list):
"""
@author : Lizhen
Version : 1.0 Created 2019.08.10
Purpose : 计算列表的平均值
Input : list —— 待计算平均值的列表
Output : cal —— 列表的平均值
"""
cal = 0.0
for each in list:
cal += each
cal = cal / len(list)
return cal
def maxabs(list):
"""
@author : Lizhen
Version : 1.0 Created 2022.05.7
Purpose : 计算列表中绝对值最大的值
Input : list —— 待计算平均值的列表
Output : cal —— 绝对值最大值
"""
cal = list[0]
for each in list:
if abs(each) > cal:
cal = abs(each)
return cal