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:
generating a random matrix

Subject: generating a random matrix

From: yafit maymon

Date: 14 Nov, 2010 11:55:06

Message: 1 of 6

hello,

i want to generate a matrix with random numbers which is similar to an exicting matrix.
for example:

i have a matrix A:
A= [ 1 , 2 , 3
                1.2 , 2.9 , 4
                4 , 5 , 2.3
                5 , 2 , 4 ]

and i woukd like to generate a same sized random matrix with the same mean , std , covariance matrix ,from a normal distribution
(it is for monte carlo process.....)

thanks
yafit

Subject: generating a random matrix

From: Matt J

Date: 14 Nov, 2010 12:50:04

Message: 2 of 6

"yafit maymon" <yafitmmn@gmail.com> wrote in message <iboimp$jpm$1@fred.mathworks.com>...
>
> and i woukd like to generate a same sized random matrix with the same mean , std , covariance matrix ,from a normal distribution
==========

How do you define the mean, std, covariance, etc... of A? Are the rows or columns of A supposed to be random samples of something?

Subject: generating a random matrix

From: Roger Stafford

Date: 14 Nov, 2010 13:04:04

Message: 3 of 6

"yafit maymon" <yafitmmn@gmail.com> wrote in message <iboimp$jpm$1@fred.mathworks.com>...
> hello,
>
> i want to generate a matrix with random numbers which is similar to an exicting matrix.
> for example:
>
> i have a matrix A:
> A= [ 1 , 2 , 3
> 1.2 , 2.9 , 4
> 4 , 5 , 2.3
> 5 , 2 , 4 ]
>
> and i woukd like to generate a same sized random matrix with the same mean , std , covariance matrix ,from a normal distribution
> (it is for monte carlo process.....)
>
> thanks
> yafit
- - - - - - - - - -
  If each row of A is regarded as an observation and each column a variable, you can apply 'mean' and 'cov' to get the "mu" and "sigma" arrays that are needed for a call to 'mvnrnd' (in the Statistics Toolbox.)

  Of course that doesn't guarantee that A would necessarily be a likely set of observations under that statistic. Matrix A might be inherently non-multivariate normal in its distribution. Also for this procedure to be statistically meaningful, there ought to be many more than just three rows.

Roger Stafford

Subject: generating a random matrix

From: yafit maymon

Date: 19 Nov, 2010 12:06:04

Message: 4 of 6

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <ibolts$it1$1@fred.mathworks.com>...
> "yafit maymon" <yafitmmn@gmail.com> wrote in message <iboimp$jpm$1@fred.mathworks.com>...
> >
> > and i woukd like to generate a same sized random matrix with the same mean , std , covariance matrix ,from a normal distribution
> ==========
>
> How do you define the mean, std, covariance, etc... of A? Are the rows or columns of A supposed to be random samples of something?

 
hi Matt,

the rows are samples of something -a vector of measurements -and i want to genetrate the same number of vectors (rows) with similar numbers for example :

i have vector A : [1, 2, 3 ,4 ,5, 6 ]
i woukd like to get something random like this (for example) :[ 1, 2.1, 3.1, 4.2, 5.3 ,6]
-the same matrix with noise in it...

thanks.
yafit

Subject: generating a random matrix

From: Tom Lane

Date: 22 Nov, 2010 16:32:08

Message: 5 of 6

> i have vector A : [1, 2, 3 ,4 ,5, 6 ]
> i woukd like to get something random like this (for example) :[ 1, 2.1,
> 3.1, 4.2, 5.3 ,6]
> -the same matrix with noise in it...

You can easily compute things like the following:

  A + rand(size(A))
  A + 0.01 * rand(size(A))
  A + 0.01 * randn(size(A))

-- Tom

Subject: generating a random matrix

From: yafit maymon

Date: 28 Nov, 2010 11:19:04

Message: 6 of 6

"Tom Lane" <tlane@mathworks.nospam.com> wrote in message <ice5u9$bsc$1@fred.mathworks.com>...
> > i have vector A : [1, 2, 3 ,4 ,5, 6 ]
> > i woukd like to get something random like this (for example) :[ 1, 2.1,
> > 3.1, 4.2, 5.3 ,6]
> > -the same matrix with noise in it...
>
> You can easily compute things like the following:
>
> A + rand(size(A))
> A + 0.01 * rand(size(A))
> A + 0.01 * randn(size(A))
>
> -- Tom
so easy....
thank you very much
yafit

Tags for this Thread

No tags are associated with 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