Function for Generating bistochastic matrix ?

Bistochastic matrix P is matrix where the sum each column or each row is 1, and aslo for n>=0 P^n is also bistochastic,
Another definition : a stochastic matrix P is bistochastic if P' is also stochastic . the question is :
Is there any predefined or sophisticated function to generate such matrices ?
I already tried a method using "magic" function :
>>H=magic(10); % say we want a Bistoch of dimension n
>>N=sum(H(1,:)); % to get the Unique SUM
>>P=H/N;
Cordially

댓글 수: 6

Matt J
Matt J 2013년 3월 17일
Is there any predefined or sophisticated function to generate such functions ?
Generate them from what?
Youssef  Khmou
Youssef Khmou 2013년 3월 17일
like generating random numbers with "rand" function, given the dimensions
Cedric
Cedric 2013년 3월 17일
The "magic" solution seems to be quite efficient already; did you ask because you need to be able to generate random bistochastic matrices?
hi Cedric, the truth is that solution respects the definition of Bistochastic matrix but the repartition of the data is quite regular, a well built function can generate such quantity with randomness quality and why not having some parameters related to well known PDFs , to see the regularity try:
H=magic(100); % say we want a Bistoch of dimension n
N=sum(H(1,:)); % to get the Unique SUM
P=H/N;
imagesc(P);
Cedric
Cedric 2013년 3월 17일
Hi Youssef, I asked precisely because of the regularity. I have no clean solution, but if I had to find some solution quickly, I would certainly go for yours, using two successive RANDPERM to permute rows and columns. It would not be optimal, but ok for a temporary approach I guess.
Youssef  Khmou
Youssef Khmou 2013년 3월 17일
alright, using Random permutation is good point , thanks

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

 채택된 답변

Matt J
Matt J 2013년 3월 17일
편집: Matt J 2013년 3월 17일

0 개 추천

Here's one idea. It uses interpMatrix ( Available Here ) to create circulant matrices, but any other method of making them would do.
function P=bistoch(N)
%Randomly generates an NxN bistochastic matrix, P
for ii=1:2
x=rand(N,1);
x=x/sum(x);
P=full(interpMatrix(x,1,length(x),1,'circ'));
A{ii}=P(randperm(N),randperm(N));
end
w=rand;
P=w*A{1}+A{2}*(1-w);

댓글 수: 3

Youssef  Khmou
Youssef Khmou 2013년 3월 17일
편집: Youssef Khmou 2013년 3월 17일
hi Mtt J,
Thanks for the answer, your function has a quality of generating randomness,
Just a small detail : The function interpMatrix.m seems to have an error :
??? Error: File: interpMatrix.m Line: 136 Column: 15
Expression or statement is incorrect--possibly unbalanced (, {, or [.
So in the line 136 :
case 'max'
[~,origin]=max(kernel);
i made an alteration :
case 'max'
[origin]=max(kernel);
And its functionning well,
Thanks .
Matt J
Matt J 2013년 3월 17일
편집: Matt J 2013년 3월 17일
Hi Youssef,
No, that is not the fix you want. You're obviously using a (very!) old MATLAB version which doesn't support tilde arguments. Substitute this instead,
[discard,origin]=max(kernel);
Youssef  Khmou
Youssef Khmou 2013년 3월 17일
alright, that is good advice, thanks :

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2013년 3월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by