-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstableValues.py
50 lines (41 loc) · 1.52 KB
/
stableValues.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
import matplotlib.pyplot as plt
import statistics
plt.style.use('seaborn-whitegrid')
plt.axis([0, 10, 0, 6])
def stableSmallest(values, stablePercent):
stablepoint = 2
stablepoints = []
countregression = 0
countstability = 0
regressionvalue = 0
KPI = []
for i in range(0, len(values)):
print(f'------------------------------------\nVALUES: {values[i]}')
upperlimit = stablepoint+1
lowerlimit = stablepoint-1
print(f'UpperLimit: {upperlimit}\nLowerLimit: {lowerlimit}')
if values[i]<=upperlimit and values[i]>=lowerlimit:
stablepoints.append(values[i])
countstability += 1
countregression = 0
else:
regressionvalue = i
print(stablepoints)
countregression += 1
countstability = 0
stablepoints.clear()
if values[i] >= upperlimit:
if countstability >= 3:
print(f'Regression At {values[i-countstability]}')
elif countregression >= 3:
print(f'Regression At {values[i-countregression]}')
if values[i] <= stablepoint:
if countstability >= 3:
print(f'stable values: {stablepoints}')
if len(stablepoints) > 0:
stablepoint = statistics.mean(stablepoints)
print(f'NEW KPI {stablepoint}')
if __name__ == "__main__":
stablePercent = 10
values = [2,2.1, 2.5, 5, 5.5, 5.6, 1, 1, 1, 1, 3]
stableSmallest(values, stablePercent)