【问题标题】:How to find a most reliable basis In a binary matrix?如何在二进制矩阵中找到最可靠的基?
【发布时间】:2017-06-20 04:25:15
【问题描述】:

我想编写一个允许执行以下指令的 MATLAB 程序,但是我遇到了一些困难,所以如果有人帮助我,我将非常感激。

设一个二进制矩阵A。从A的第一列开始,找到前K个线性独立的列,关联可靠性值最大。然后,将这 K 个线性独立的列用作新矩阵 B 的前 K 列,保持它们的可靠性顺序。 B 的其余 (N - K) 列也按可靠性降序排列。

例子:

A = [1 0 0 1 0 0 1 1;
     0 1 0 1 1 0 0 1;
     0 0 1 1 1 0 1 0;
     0 0 0 0 1 1 1 1]

A的前三列线性独立,第五列与前三列线性独立。

我们发现:

B = [1 0 0 0 1 0 1 1;
     0 1 0 1 1 0 0 1;
     0 0 1 1 1 0 1 0;
     0 0 0 1 0 1 1 1]

【问题讨论】:

  • 最大相关可靠性值”是什么意思?
  • 矩阵A的列根据其可靠性值进行分类,即第一列比第二列更可靠,第二列比第三列更可靠,依此类推。跨度>

标签: matlab matrix


【解决方案1】:

您可以使用rank 来确定列是否线性独立,如下所示:

K = size(A, 1); % the number of linearly independent columns to find
B = zeros(size(A)); % preallocate output for efficiency
colB = 1; % column index for the next linearly independent column
colBafter = K + 1; % column index for the next linearly dependent column

for i=1:size(A, 2) % loop over all columns in A
  B(:, colB) = A(:, i); % add the next column of A as an independent column to B
  if rank(B(:, 1:colB)) == colB % check if the newly added column is indeed linearly independent
    if colB == K % check if all independent columns are found
      break;
    else
      colB = colB + 1; % increase the independent index as the added column was indeed linearly independent
    end
  else
    B(:, colBafter) = A(:, i); % add the column as a dependent column to B
    colBafter = colBafter + 1; % increase the dependent index as the added column was linearly dependent
  end
end

B(:, colBafter:end) = A(:, i+1:end); % copy the rest of A to B

【讨论】:

  • 谢谢@m7913d!这正是我一直在寻找的。​​span>
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-09-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-03
  • 2013-01-16
  • 2017-10-11
相关资源
最近更新 更多