-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstableValues2.py
66 lines (53 loc) · 1.86 KB
/
stableValues2.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
import matplotlib.pyplot as plt
import statistics
plt.style.use('seaborn-whitegrid')
# plt.axis([0, 10, 0, 6])
plt.figure()
def stableSmallest(values, stablePercent):
stablepoint = 2
stablepoints = []
countregression = 0
countstability = 0
regressionvalue = 0
KPI = []
upperlimit = []
lowerlimit = []
plt.plot(values)
stabpts = []
for i in range(0, len(values)):
print(f'------------------------------------\nVALUES: {values[i]}')
upperlimit.append(stablepoint+1)
lowerlimit.append(stablepoint-1)
stabpts.append(stablepoint)
print(f'UpperLimit: {upperlimit[-1]}\nLowerLimit: {lowerlimit[-1]}')
if values[i]<=upperlimit[-1] and values[i]>=lowerlimit[-1]:
stablepoints.append(values[i])
countstability += 1
countregression = 0
else:
regressionvalue = i
print(stablepoints)
countregression += 1
countstability = 0
stablepoints.clear()
if values[i] >= upperlimit[-1]:
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}')
plt.plot(lowerlimit)
plt.plot(upperlimit)
plt.plot(stabpts)
plt.legend(['Values','Lower Limit','Upper Limit','KPI'])
plt.show()
if __name__ == "__main__":
stablePercent = 10
values = [2,2.1, 2.5, 2.6, 2.8, 5, 5.5, 5.6, 1, 1, 1, 0.3, 0.3, 0.2, 0.1]
stableSmallest(values, stablePercent)
plt.show()