필터 지우기
필터 지우기

How to have Matlab create a random matrix that is fullrow rank?

조회 수: 23 (최근 30일)
DB
DB 2022년 3월 24일
편집: Bruno Luong 2022년 3월 30일
Say we have random matrix A, which we use for proving some theory, and we need this matrix to be fullrow rank, how to model this in Matlab?
I have no numeric values, as I want to research the generality of the theory.
  댓글 수: 2
jessupj
jessupj 2022년 3월 24일
can you clarify what you mean by 'random' here? Requiring a rank imposes some constraint (e.g noncollinearity or something like that) on the entries, so they will coordinate with one another rather than being independent. I think this may be one of those things that you have to think out a strategy on paper first before trying to assemble it numerically.
DB
DB 2022년 3월 25일
A random generated matrix that is subject to being full row rank

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2022년 3월 24일
편집: Matt J 2022년 3월 24일
rand() or randn() should give you a full row rank (in probability one) matrix provided there are fewer rows than columns.
rank(randn(3,4))
ans = 3
  댓글 수: 4
David Goodmanson
David Goodmanson 2022년 3월 29일
편집: David Goodmanson 2022년 3월 30일
Hello jessupj,
I am not quite sure what you mean here. The 'should give' that you comment on, it's perfectly fine to replace it with 'will give'. Rand produces something on the order of 10^16 random numbers, meaning that the probability of producing a matrix of any sensible size that is less than full rank is vanishingly small. Creating a matrix that does not obey the desired full rank property is not going to happen. What might conceivably happen, I suppose, is that Matlab assays a full rank matrix as less than full rank due to numerical issues. But that is a different consideration, one of numerical precision rather than truly not satisfying the desired property.
Bruno Luong
Bruno Luong 2022년 3월 30일
편집: Bruno Luong 2022년 3월 30일
By curiosity I run a monte-carlo to see a distribution condition numbers of matrices 1000x1000 generated with of rand(), caution it takes a while for the script to finish; and I get this result of histogram
There is a non negligible cases where the conditionumber goes above 1/eps('single') (1about 10^7). The maximum reaches 1.1263e+09
So for single precision numerical rank is a real problem and cannot be ignored.
ntests=10000;
m=1000;
cs=zeros(1,ntests);
for k=1:ntests,
cs(k)=cond(rand(m,'single'));
end;
figure;
histogram(log10(cs));
xlabel('log_{10} cond');
ylabel('distribution');
title('rand(m,''single'')');

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Bruno Luong
Bruno Luong 2022년 3월 29일
편집: Bruno Luong 2022년 3월 29일
Here is a way to generate finite condition number matrxix , meaning stronger than full rank, and it must give a full rank (unless randn(n) returns all 0s)
targetcond = 10; % must be > 1
n = 1000;
[U,S,V] = svd(randn(n,n), 0, 'vector');
Sc = ((targetcond-1)*S + S(1))/targetcond;
A = U*diag(Sc)*V';
% Check
cond(A)
ans = 9.9939

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by