-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_norm_test.m
125 lines (100 loc) · 3.11 KB
/
data_norm_test.m
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
%% Set Training Data in terms of x,y cordinates.
data = [];
% % ai data
data_ai = dlmread('ai.ldf');
training_rows = uint16(0.7 * size(data_ai,1));
data_ai = data_ai(training_rows+1:size(data_ai,1),2:size(data_ai,2));
% % la data
data_la = dlmread('lA.ldf');
training_rows = uint16(0.7 * size(data_la,1));
data_la = data_la(training_rows+1:size(data_la,1),2:size(data_la,2));
% % ta data
data_ta = dlmread('tA.ldf');
training_rows = uint16(0.7 * size(data_ta,1));
data_ta = data_ta(training_rows+1:size(data_ta,1),2:size(data_ta,2));
%% Concatenate all the data
for i=1:size(data_ai,1)
j=1;
k=1;
temp = [];
run = true;
while (j<=size(data_ai,2) && run == true)
if(data_ai(i,j) == 0)
run = false;
else
temp(k,1) = data_ai(i,j);
temp(k,2) = data_ai(i,j+1);
end
k = k+1;
j = j+2;
end
mean_x = compute_mean(temp(:,1));
std_dev_x = compute_std_deviation(temp(:,1),mean_x);
temp(:,1) = 1/std_dev_x * (temp(:,1) - mean_x * ones(size(temp,1),1));
mean_y = compute_mean(temp(:,2));
std_dev_y = compute_std_deviation(temp(:,2),mean_y);
temp(:,2) = 1/std_dev_y * (temp(:,2) - mean_y * ones(size(temp,1),1));
data = [data;temp];
end
for i=1:size(data_la,1)
j=1;
k=1;
temp = [];
run = true;
while (j<=size(data_la,2) && run == true)
if(data_la(i,j) == 0)
run = false;
else
temp(k,1) = data_la(i,j);
temp(k,2) = data_la(i,j+1);
end
k = k+1;
j = j+2;
end
mean_x = compute_mean(temp(:,1));
std_dev_x = compute_std_deviation(temp(:,1),mean_x);
temp(:,1) = 1/std_dev_x * (temp(:,1) - mean_x * ones(size(temp,1),1));
mean_y = compute_mean(temp(:,2));
std_dev_y = compute_std_deviation(temp(:,2),mean_y);
temp(:,2) = 1/std_dev_y * (temp(:,2) - mean_y * ones(size(temp,1),1));
data = [data;temp];
end
for i=1:size(data_ta,1)
j=1;
k=1;
temp = [];
run = true;
while (j<=size(data_ta,2) && run == true)
if(data_ta(i,j) == 0)
run = false;
else
temp(k,1) = data_ta(i,j);
temp(k,2) = data_ta(i,j+1);
end
k = k+1;
j = j+2;
end
mean_x = compute_mean(temp(:,1));
std_dev_x = compute_std_deviation(temp(:,1),mean_x);
temp(:,1) = 1/std_dev_x * (temp(:,1) - mean_x * ones(size(temp,1),1));
mean_y = compute_mean(temp(:,2));
std_dev_y = compute_std_deviation(temp(:,2),mean_y);
temp(:,2) = 1/std_dev_y * (temp(:,2) - mean_y * ones(size(temp,1),1));
data = [data;temp];
end
function mean = compute_mean(input_data)
data = input_data;
sum_data = sum(data);
data_size = size(data,1);
mean = sum_data/data_size;
end
function std_deviation = compute_std_deviation(input_data,input_mean)
data = input_data;
mean = input_mean;
data_size = size(data,1);
t = data - mean * ones(data_size,1);
t = t.*t;
t_sum = sum(t);
variance = t_sum/(data_size - 1);
std_deviation = sqrt(variance);
end