-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreshold.py
More file actions
53 lines (46 loc) · 1.15 KB
/
Threshold.py
File metadata and controls
53 lines (46 loc) · 1.15 KB
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
import statistics
class Threshold():
def __init__(self):
pass
def transform(self,signal,media):
for i in range(len(signal)):
s = signal[i]
if(s<=media):
s=0
signal[i] = s
return signal
def media(self,signal):
med = 0
i=0
for s in signal:
if(s>0):
med+=s
i+=1
return med/i
def threshold_mean(self,data):
thresh_value = self.media(data)
indexes = []
i=0
for d in data:
if(d>thresh_value):
indexes.append(i)
i+=1
return indexes
def threshold_median(self,data):
thresh_value = statistics.median(data)
indexes = []
i=0
for d in data:
if(d>thresh_value):
indexes.append(i)
i+=1
return indexes
def threshold_deviation(self,data):
thresh_value = statistics.stdev(data)
indexes = []
i=0
for d in data:
if(d>thresh_value):
indexes.append(i)
i+=1
return indexes