Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to genereate a n*n probality transition matrix
Date: Sat, 3 Apr 2010 03:46:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 29
Message-ID: <hp6dlr$s75$1@fred.mathworks.com>
References: <hp3lln$fka$1@fred.mathworks.com> <hp64jp$2f2$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1270266363 28901 172.30.248.38 (3 Apr 2010 03:46:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 3 Apr 2010 03:46:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:623068

"Sadik " <sadik.hava@gmail.com> wrote in message <hp64jp$2f2$1@fred.mathworks.com>...
> Hi Devanand,
> 
> P = rand(n,n);
> rowSums = sum(P,2);
> normalizingMatrix = repmat(rowSums,1,n);
> P = P./normalizingMatrix;
> 
> Now, sum(P,2) should give you a vector of ones [if I didn't make any typos :)].
> 
> For each line, you can check the documentation by typing, say,
> 
> doc repmat
> 
> Best.

Hi Sadik,

  It should be realized that, as predicted at by the Central Limit Theorem of statistics, this kind of normalization will result in a distribution which is densest at the center of the n-1 dimensional simplex result and dropping down toward zero at its vertices, rather than a uniform distribution.

  Try plotting it with 'plot3' for n = 3.  All the points' yellow dots in the rows of P will fall in the two-dimensional equilateral space triangle outlined in red.  Observe that these dots are clustered most closely at the triangle's center and become noticeably sparser near its three vertices.

 P = rand(3000,3);
 rowSums = sum(P,2);
 normalizingMatrix = repmat(rowSums,1,3);
 P = P./normalizingMatrix;
 plot3(P(:,1),P(:,2),P(:,3),'y.',[1,0,0,1],[0,1,0,0],[0,0,1,0],'r-')

Roger Stafford