-
Notifications
You must be signed in to change notification settings - Fork 0
/
Road-Accident-Identifier-Tool.txt
40 lines (40 loc) · 1.91 KB
/
Road-Accident-Identifier-Tool.txt
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
# Using a sample of the accelerometer x, y, z data (50 lines).
# Purpose of code is to identify big rates of change in the data series, take an
# average of the absolute value of the change accross the three given dimensions for
# each time slice, and use a normal distribution to filter 3 sigma and 4 sigma events as possible accidents.
# As with any series the tool will become more stable once its has filtered over a large enough (5000+) training set.
import statistics
import numpy
x = (1, 1, 1, 1, 1, -4, 3, 2, 1, 1, 1, 2, 3)
y = (1, 1, 1, 1, 1, 4, 3, -2, 1, 1, 1, 2, 3)
z = (1, 1, 1, 1, 1, 4, -3, 2, 1, 1, 1, 2, 3)
List = []
PossibleAccident = []
ProbableAccident = []
HighlyLikelyAccident = []
a = 0
a = int(a)
while a < len(x)-1:
Value = (abs((x[a+1]/x[a]))+abs((y[a+1]/y[a]))+abs((z[a+1]/z[a])))/3
List.insert(len(List), Value)
print(List)
print("Maximum acceleration delta", max(List))
print("Minimum acceleration delta", min(List))
print("Average acceleration delta", statistics.mean(List))
a+=1
for i in List:
if i > max(List)*0.7:
print("High Value",i)
print("List Standard Deviation is",numpy.std(List))
if i > (statistics.mean(List)+(numpy.std(List)*3)):
print("Outlier and possible accident", i, List.index(i))
PossibleAccident.insert(len(List), (i, List.index(i)))
print("PossibleAccidents", PossibleAccident)
if i > (statistics.mean(List)+(numpy.std(List)*3.5)):
print("Outlier and probable accident", i, List.index(i))
ProbableAccident.insert(len(List), (i, List.index(i)))
print("ProbableAccidents", ProbableAccidents)
if i > (statistics.mean(List)+(numpy.std(List)*4)):
print("Outlier and highly likely to be an accident", i, List.index(i))
HighlyLikelyAccident.insert(len(List), (i, List.index(i)))
print("HighlyLikelyAccident", HighlyLikelyAccident)