Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to genereate a n*n probality transition matrix

Subject: How to genereate a n*n probality transition matrix

From: DEVANAND

Date: 2 Apr, 2010 02:44:07

Message: 1 of 9

How to genereate a n*n probality transition matrix P such that the sum of n elements in a row is unity.I need to generate this many times for my project.Please help.

Subject: How to genereate a n*n probality transition matrix

From: Sadik

Date: 3 Apr, 2010 01:11:21

Message: 2 of 9

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.

Subject: How to genereate a n*n probality transition matrix

From: DEVANAND

Date: 3 Apr, 2010 03:00:23

Message: 3 of 9

"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.

Thanks very much , Sadik

Subject: How to genereate a n*n probality transition matrix

From: Roger Stafford

Date: 3 Apr, 2010 03:46:03

Message: 4 of 9

"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

Subject: How to genereate a n*n probality transition matrix

From: Sadik

Date: 3 Apr, 2010 04:36:05

Message: 5 of 9

Hi Roger,

I think your explanation is awesome. Thanks!

In fact, I didn't ever mean to produce something that is of uniform distribution nature. The OP just wanted to generate any matrix whose rows added up to 1. This is why I picked rand.

Thanks again.

Best.

Subject: How to genereate a n*n probality transition matrix

From: DEVANAND

Date: 5 Apr, 2010 01:55:08

Message: 6 of 9

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hp6dlr$s75$1@fred.mathworks.com>...
> "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
Thanks again sir.

Subject: Can you please clear this concept

From: DEVANAND

Date: 21 Aug, 2012 08:01:09

Message: 7 of 9

Hi Roger ,
                  I am Devanand T from India. It will be very helpful if you
clear me the following concept related to this post :


P = rand(n,n);
> rowSums = sum(P,2);
> normalizingMatrix = repmat(rowSums,1,n);
> P = P./normalizingMatrix;
>

**
>
> * 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.*


If there is any problem in generating conditional probability matrix like that, how to
overcome that.

Regards,
Devanand T

Subject: Can you please clear this concept

From: Torsten

Date: 21 Aug, 2012 09:05:02

Message: 8 of 9

On 21 Aug., 10:01, "DEVANAND " <devanandiam...@gmail.com> wrote:
> Hi Roger ,
> I am Devanand T from India. It will be very helpful if you
> clear me the following concept related to this post :
>
> P = rand(n,n);
>
> > rowSums = sum(P,2);
> > normalizingMatrix = repmat(rowSums,1,n);
> > P = P./normalizingMatrix;
>
> **
>
> > * 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.*
>
> If there is any problem in generating conditional probability matrix like that, how to
> overcome that.
>
> Regards,
> Devanand T

http://stats.stackexchange.com/questions/14059/generate-uniformly-distributed-weights-that-sum-to-unity

Best wishes
Torsten.

Subject: Can you please clear this concept

From: Bruno Luong

Date: 21 Aug, 2012 09:16:07

Message: 9 of 9

Torsten <Torsten.Hennig@umsicht.fraunhofer.de> wrote in message <4c56df71-bd7b-41bc-9ed0-c46b12474cda@z4g2000vby.googlegroups.com>...
>
> http://stats.stackexchange.com/questions/14059/generate-uniformly-distributed-weights-that-sum-to-unity
>

It looks like the exact method I used in the first part of my code to another thread opened by OP:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/322373#885550

Bruno

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us