Let me create a random matrix of a) There are exactly Assume I (all of This code: This code: plot (amount (m, 2)) conditioned a) not satisfied satisfies the situation a) and partly condition b). I say partly because until NN & gt; & Gt; N will be less than each of each <\ n> in the last matrix. Is there a better and faster way to solve the problem cycle and N & gt; & Gt; Need for N? First of all, n Generate: Then generate the match line index: And finally create this rare matrix with: To get the full form of the matrix, use The result I got: This calculation should be very fast here of = 30, of = 4, of and N > N = The result for 10000 was obtained in less than 0.01 seconds. of columns and
N I need rows of those rows and zeros such as:
k in each line. B) Each row is different from the other (the organizer imposes that if
n >
nchoosek (K, k) will be
nchoosek (K, k) rows).
nchoosek (K, K) = 27405 ), separate 1 Q vector (with
K = 30 <)>
N = 10000 / Code>) with the K (
k = 4 ) and
K - k zeroes.
clear all; Closed N = 10000; K = 30; K = 4; M = Randi ([0 1], N, K);
clear all; Close; N = 10000; NN = N; K = 30; K = 4; TempM = zero (NN, K); For IE = 1: NN TTModel = TAMPM (ii, :); Ttmodel (randsample (k, k, false)) = 1; % Satisfies the condition a) tempM (ii, :) = ttmodel; End check = bi2de (tempM); From binary to decimal [tresh1, ind, tresh2] = unique (check);% Vatric drop which appears more than once in the matrix M = temp (ind, :); % And satisfied position B) Plot (Amount (M, 2)) Confirms that the condition is to attract the% effective draw, the wanted draw, the number of possible combinations [sum (sum, m, 2) == k ) N. Nokokak (K, K)]
cols = randperm (K, N); Cols = cols (:, 1: k);
line = meshgrid (1: N, 1: k) ';
A = sparse (rows, columns, 1, n, k);
complete (a) .
example
of = 10; K = 4; N = 5; Cols = randperm (K, N); Cols = cols (:, 1: k); Line = meshgrid (1: n, 1: k) '; A = sparse (rows, columns, 1, n, k); Full (A)
ans = 1 1 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 0 1 0 0 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0
No comments:
Post a Comment