Thread Subject: Random matrix/normal distribution

Subject: Random matrix/normal distribution

From: Michael Grosswald

Date: 29 Sep, 2009 20:07:02

Message: 1 of 5

I'm trying to generate random matrices whose entries are from the normal distribution.

Something like this:

(1/(sqrt(2*pi)))*exp(-(1+99*rand(5))^2/2)

Isn't going to work because squaring a matrix doesn't square each entry. How can I correct this or am I going about this the wrong way.

I'm still a MATLAB beginner so go easy on me!

Subject: Random matrix/normal distribution

From: dpb

Date: 29 Sep, 2009 20:09:13

Message: 2 of 5

Michael Grosswald wrote:
> I'm trying to generate random matrices whose entries are from the normal distribution.
>
> Something like this:
>
> (1/(sqrt(2*pi)))*exp(-(1+99*rand(5))^2/2)
>
> Isn't going to work because squaring a matrix doesn't square each
> entry. How can I correct this or am I going about this the wrong way.

> I'm still a MATLAB beginner so go easy on me!


Well,

lookfor normal

returns

 >> lookfor normal
RANDN Normally distributed random numbers.
...
SPRANDN Sparse normally distributed random matrix.
...

which might look interesting... :)

As for the question on squaring terms in an array (or vector), look at
".*" instead of "*"

--

Subject: Random matrix/normal distribution

From: Doug Hull

Date: 29 Sep, 2009 20:14:02

Message: 3 of 5

A .^ 2

This will take your matrix and square it element by element.

.* is similar.

Doug

"Michael Grosswald" <michaelgrosswald@yahoo.co.uk> wrote in message <h9tpd6$bh9$1@fred.mathworks.com>...
> I'm trying to generate random matrices whose entries are from the normal distribution.
>
> Something like this:
>
> (1/(sqrt(2*pi)))*exp(-(1+99*rand(5))^2/2)
>
> Isn't going to work because squaring a matrix doesn't square each entry. How can I correct this or am I going about this the wrong way.
>
> I'm still a MATLAB beginner so go easy on me!

Subject: Random matrix/normal distribution

From: Michael Grosswald

Date: 29 Sep, 2009 21:20:04

Message: 4 of 5

Thanks a lot to both of you.

Subject: Random matrix/normal distribution

From: Tom Lane

Date: 30 Sep, 2009 14:32:19

Message: 5 of 5

> I'm trying to generate random matrices whose entries are from the normal
> distribution.
>
> Something like this:
>
> (1/(sqrt(2*pi)))*exp(-(1+99*rand(5))^2/2)
>
> Isn't going to work because squaring a matrix doesn't square each entry.
> How can I correct this or am I going about this the wrong way.

Michael, if you square the matrix, this will give you values of the normal
density function evaluated at random points. I encourage you to try the
advice from dbp instead of squaring the matrix in this formula.

-- Tom

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
array power Doug Hull 29 Sep, 2009 16:19:05
multiplication Doug Hull 29 Sep, 2009 16:19:05
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com