-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSkillForgOthers_RandForg.m
More file actions
124 lines (119 loc) · 2.53 KB
/
SkillForgOthers_RandForg.m
File metadata and controls
124 lines (119 loc) · 2.53 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
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
function [ xi,xj,y,xi_t,xj_t,y_t ] = SkillForgOthers_RandForg(X,p,ng,nf,ng_,nf_)
Total=115;
N=size(X,2);
GenP=((ng)*(ng-1)/2 )+ng
GenOthers=((ng_*(ng_-1)/2 )+ng_)*(Total-1)
Skilled=0 ; %ng_*nf_*(Total-1)
RandomforOne=0 %(ng*nf*(Total-1))
RandomforOthers=(ng_*nf_)*(Total)*(Total-1)
xis= GenP + GenOthers + Skilled + RandomforOne + RandomforOthers
xi=zeros(xis,2); xj=xi; y=zeros(xis,1);
c=0;
%% Genuine
for p_=1:Total
if p_==p
for i=1:ng
for j=i:ng
c=c+1;
% xi(c,:)=reshape(X(p_,:,i),N,1,1)';
% xj(c,:)=reshape(X(p_,:,j),N,1,1)';
xi(c,:)=[p_ i];
xj(c,:)=[p_ j];
y(c,:)=1;
end
end
else
for i=1:ng_
for j=i:ng_
c=c+1;
% xi(c,:)=reshape(X(p_,:,i),N,1,1)';
% xj(c,:)=reshape(X(p_,:,j),N,1,1)';
xi(c,:)=[p_ i];
xj(c,:)=[p_ j];
y(c,:)=1;
end
end
end
end
%% skilled Forgery
% for p_=1:Total
% % p_;
% if p_~=p
% for i=1:ng_
% for j=28:27+nf_
% c=c+1;
% % xi(c,:)=reshape(X(p_,:,i),N,1,1)';
% % xj(c,:)=reshape(X(p_,:,j),N,1,1)';
% xi(c,:)=[p_ i];
% xj(c,:)=[p_ j];
% y(c,:)=-1;
% end
% end
% end
% end
%% Random Forgery just for p vs others
% for i=1:ng
% for p_=1:Total
% if p_~=p
% for j=1:nf
% c=c+1;
% % xi(c,:)=reshape(X(p,:,i),N,1,1)';
% % xj(c,:)=reshape(X(p_,:,j),N,1,1)';
% xi(c,:)=[p i];
% xj(c,:)=[p_ j];
% y(c,:)=-1;
% end
% end
% end
% end
% Random Forgery for Others
% c=0;
for p_g=1:Total
for p_=1:Total
if p_g~=p_
for i=1:ng_
for j=1:nf_
c=c+1;
xi(c,:)=[p_g i];
xj(c,:)=[p_ j];
y(c,:)=-1;
end
end
end
end
end
%% Test
xis= (ng*(27-ng)) + 45*ng ;% + (Total-1)*(ng*72);
xi_t=zeros(xis,N); xj_t=xi_t; y_t=zeros(xis,1);
c=0;
% Genuine
for j=ng+1:27
for i=1:ng
c=c+1;
xi_t(c,:)=reshape(X(p,:,i),N,1,1)';
xj_t(c,:)=reshape(X(p,:,j),N,1,1)';
y_t(c,:)=1;
end
end
% Skilled Forgery
for j=28:72
for i=1:ng
c=c+1;
xi_t(c,:)=reshape(X(p,:,i),N,1,1)';
xj_t(c,:)=reshape(X(p,:,j),N,1,1)';
y_t(c,:)=-1;
end
end
% Random Forgery
% for p_=1:Total
% if p_~=p
% for j=1:72
% for i=1:ng
% c=c+1;
% xi_t(c,:)=reshape(X(p,:,i),N,1,1)';
% xj_t(c,:)=reshape(X(p_,:,j),N,1,1)';
% y_t(c,:)=-1;
% end
% end
% end
% end