clc;clear;
K = 10000;%%%%%%%%%%%%%
m = K;
c = 0.01;
o = 0.5;
x = ones(1,m);
S = c*sqrt(K)*log(K/o);
for cou_num = 1:100 %½yÓ‹ %%%%%%%%%
x_1 = rand(1,m)<0.5 ; %ÐÅÔ´´a×Ö %%%%%%%%%
generate = rand(1,12000); %Éú³ÉëS™C”µ%%%%%%%%%
n = 10000; %%%%%%%%%%%%%%%%%%
while(n<=12000) %%%%%%%%%%%%%%%%%
Pgenerate = generate(1,1:n);
Z = 0;
for d = 1:K
index_d = 2:K;
if find(d==index_d)
PP = 1/d/(d-1);
elseif d==1
PP = 1/K;
end
P_P(d) = PP;
d_index = 1:round(K/S)-1;
if (find(d==d_index))
tt = S/K/d;
elseif d==round(K/S)
tt = S/K*log(S/o);
else
tt = 0;
end
t(d) = tt;
Z = Z + P_P(d)+t(d);
end
P_P;
t;
Z;
for d = 1:K
P(d) = (P_P(d)+t(d))/Z;
end
P;
sum = 0;
for i = 1:K
sum = sum + P(i);
sum_1(i) = sum;
end
sum_1;
for j = 1:length(Pgenerate)
for i = 1:length(sum_1)
if Pgenerate(j)<sum_1(i)
label(j) = i;
break;
end
end
end
label;
for j = 1:n
a = zeros(1,m);
vector = randperm(m,label(j));
for i = 1:length(vector)
a(vector(i)) = 1;
end
G(1:m,j) = a;
end
y = mod(x_1*G,2); %生æˆç¢¼å—
while(1) %è¯ç¢¼
%***********判斷準備開始1*****************
for i = 1:n
front_judge(i) = length(find(G(:,i)==1));
end
%***********判斷準備çµæŸ1*****************
count = zeros(1,n);
for j = 1:n
index_1 = find(G(:,j)==1);
if length(index_1)==1 %æ¢ä»¶æ»¿è¶³
count(j) = index_1;
x(index_1) = y(j);
G(index_1,j) = 0;
end
end
t = 1;
countt = zeros(1,length(find(count~=0)));
for j = 1:n
if count(j)~=0
countt(t) = count(j);
t = t + 1;
end
end
for i = 1:length(countt) %æ©«å標count
for j = 1:n
if G(countt(i),j) == 1
y(j) = xor(x(countt(i)),y(j));
G(countt(i),j) = 0;
end
end
end
%***********判斷準備開始2*****************
for i = 1:n
last_judge(i) = length(find(G(:,i)==1));
end
%***********判斷準備çµæŸ2*****************
if last_judge==front_judge
break;
end
end
x_2 = x; %%%%%%%%%%%%%%%%%%%%
x_1 ; %%%%%%%%%%%%%%%%%%%%
sum = 0;
for i = 1:m
if x_1(i)~=x_2(i)
sum = sum + 1;
end
end
sum;
if sum~=0 %×g´aʧ”¡
n = n + 50;%%%%%%%%%%%%%%%%%%%%%%%%%%%
else %×g´a³É¹¦
record_result = n; %ӛ䛽Y¹û
break;
end
end
record_result;
record_finished(cou_num) = record_result;
end
LT_柱状图
最新推荐文章于 2022-03-15 16:12:38 发布