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:
multivariate normal distribution sample

Subject: multivariate normal distribution sample

From: debi mishra

Date: 15 Apr, 2005 06:39:57

Message: 1 of 7

i have a vector M of size ( 10 x 1) another vector V(10 x 10).
  V represents co-variance matrix and M represents Gaussian mean.
  M has gaussian mean and V represents corresponding covariance
represented by corresponding row.

 I want to find "multivariate normal distribution sample" from M and
V.
 Can any one give me how to find it using matlab.

Pls mail me at:debi_sit@yahoo.co.in

Subject: multivariate normal distribution sample

From: Peter Perkins

Date: 15 Apr, 2005 09:35:21

Message: 2 of 7

debi mishra wrote:

> I want to find "multivariate normal distribution sample" from M and
> V.

If you have the Statistics Toolbox:
    r = mvnrnd(M,V,n);

If not:
    r = repmat(M,n,1) + randn(n,length(M))*chol(V);

Hope this helps.

- Peter Perkins
   The MathWorks, Inc.

Subject: multivariate normal distribution sample

From: debi mishra

Date: 16 Apr, 2005 00:10:11

Message: 3 of 7

Peter Perkins wrote:
>
>
> debi mishra wrote:
>
>> I want to find "multivariate normal distribution sample" from
M
> and
>> V.
>
> If you have the Statistics Toolbox:
> r = mvnrnd(M,V,n);
>
> If not:
> r = repmat(M,n,1) + randn(n,length(M))*chol(V);
>
> Hope this helps.
>
> - Peter Perkins
> The MathWorks, Inc.
>

I have Statistics Toolbox.But from your reply i cannot understand
what to write in place of 'n' in the command
mvnrnd.So please help.
                       Thank you

Subject: multivariate normal distribution sample

From: Peter Perkins

Date: 18 Apr, 2005 09:32:18

Message: 4 of 7

debi mishra wrote:

> I have Statistics Toolbox.But from your reply i cannot understand
> what to write in place of 'n' in the command
> mvnrnd.So please help.

help mvnrnd:

"R = MVNRND(MU,SIGMA,CASES) returns a CASES-by-d matrix R of random
vectors chosen from the multivariate normal distribution with a common
1-by-d mean vector MU, and a common d-by-d covariance matrix SIGMA."

n is the number of random vectors that you want back from MVNRND.

 >> mvnrnd([1 2], [4 2; 2 1], 10)
ans =
        1.8651 2.4326
        4.3312 3.6656
       0.74934 1.8747
       0.42465 1.7123
        3.2929 3.1465
       -1.3818 0.80908
       -1.3783 0.81084
        1.0753 2.0376
       0.34542 1.6727
       0.65072 1.8254


Hope this helps.

Subject: multivariate normal distribution sample

From: Sheng-Yun

Date: 25 Sep, 2009 05:44:23

Message: 5 of 7

"debi mishra" <debi_sit@yahoo.co.in> wrote in message <ef02eab.1@webx.raydaftYaTP>...
> Peter Perkins wrote:
> >
> >
> > debi mishra wrote:
> >
> >> I want to find "multivariate normal distribution sample" from
> M
> > and
> >> V.
> >
> > If you have the Statistics Toolbox:
> > r = mvnrnd(M,V,n);
> >
> > If not:
> > r = repmat(M,n,1) + randn(n,length(M))*chol(V);
> >
> > Hope this helps.
> >
> > - Peter Perkins
> > The MathWorks, Inc.
> >
>
> I have Statistics Toolbox.But from your reply i cannot understand
> what to write in place of 'n' in the command
> mvnrnd.So please help.
> Thank you

Dear Peter,
     Because I did not get statistics toolbox, I tried r = repmat(M,n,1) + randn(n,length(M))*chol(V). However Matlab gave me a warning:
??? Error using ==> plus
Matrix dimensions must agree.
     Would you please tell me what I should do? Thank you.

Nathalie

Subject: multivariate normal distribution sample

From: Peter Perkins

Date: 25 Sep, 2009 13:32:47

Message: 6 of 7

Sheng-Yun wrote:

> Dear Peter,
> Because I did not get statistics toolbox, I tried r = repmat(M,n,1) + randn(n,length(M))*chol(V). However Matlab gave me a warning:
> ??? Error using ==> plus
> Matrix dimensions must agree.
> Would you please tell me what I should do? Thank you.

The error message tells you exactly what the problem is, and where it is happening. Evaluete the two halves of the expression, look at their sizes, and figure out what you've done wrong.

Subject: multivariate normal distribution sample

From: Tom Lane

Date: 25 Sep, 2009 13:36:51

Message: 7 of 7

> Because I did not get statistics toolbox, I tried r = repmat(M,n,1) +
> randn(n,length(M))*chol(V). However Matlab gave me a warning:
> ??? Error using ==> plus
> Matrix dimensions must agree.
> Would you please tell me what I should do? Thank you.

Nathalie, I don't know what values all these variables have for you, but
this code is appropriate when M is defined as a row vector rather than a
column vector. Make sure that's true. If that's not the problem, I'd have to
know the value of n and the sizes of M and V.

-- Tom

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