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:
generate complicate dataset

Subject: generate complicate dataset

From: Sheng-Yun

Date: 6 Oct, 2009 03:43:02

Message: 1 of 2

I’m using Matlab to generate some data. But I had some difficulties in doing so. Would you please help me? Thank you.
        Here is my question:

       I want to generate 12 random data with known distribution, mean values and standard deviations. However, there are correlations between variable 1, 5 and 9 (that is, there are three correlations, P15, P19, and P59). The left variables are independent.

     I read one of Roger's response about how to generate two datasets with correlations. I attached the response below:

    u = randn(1,n);
    v = randn(1,n);
    x = s1*u+m1;
    y = s2*(p*u+sqrt(1-p^2)*v)+m2;

   Then x and y are each n-element row vectors having the required joint distributions.

     But what should I do with three correlations? I do not have statistics toolbox.

    Thank you very much.

Subject: generate complicate dataset

From: Bruno Luong

Date: 6 Oct, 2009 07:05:20

Message: 2 of 2

"Sheng-Yun " <qxl21cn@yahoo.com.cn> wrote in message <haeec6$7t6$1@fred.mathworks.com>...
> I’m using Matlab to generate some data. But I had some difficulties in doing so. Would you please help me? Thank you.
> Here is my question:
>
> I want to generate 12 random data with known distribution, mean values and standard deviations. However, there are correlations between variable 1, 5 and 9 (that is, there are three correlations, P15, P19, and P59). The left variables are independent.
>
> I read one of Roger's response about how to generate two datasets with correlations. I attached the response below:
>
> u = randn(1,n);
> v = randn(1,n);
> x = s1*u+m1;
> y = s2*(p*u+sqrt(1-p^2)*v)+m2;
>
> Then x and y are each n-element row vectors having the required joint distributions.
>
> But what should I do with three correlations? I do not have statistics toolbox.
>

A=eye(15);
P15=0.5;
P19=0.2;
P59=-0.7;
A(1,5)=P15; A(5,1)=P15;
A(1,9)=P19; A(9,1)=P19;
A(5,9)=P59; A(9,5)=P59;

x = sqrtm(A)*randn(15,1)

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