Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From: Jeff <milleratotago@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Generate three correlated variables
Date: Mon, 12 Mar 2012 16:22:21 -0700 (PDT)
Organization: http://groups.google.com
Lines: 21
Message-ID: <6525364.3539.1331594541033.JavaMail.geo-discussion-forums@pbij6>
References: <jjl4q3$pab$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: 139.80.61.47
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1331594964 22668 127.0.0.1 (12 Mar 2012 23:29:24 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 12 Mar 2012 23:29:24 +0000 (UTC)
Cc: Gabriela Sicilia <gsicilia@gmail.com>
In-Reply-To: <jjl4q3$pab$1@newscl01ah.mathworks.com>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=139.80.61.47; posting-account=nd8I7gkAAAAk0q-yI51G_oj5pmpGOX6S
User-Agent: G2/1.0
Xref: news.mathworks.com comp.soft-sys.matlab:760730

On Tuesday, March 13, 2012 4:30:11 AM UTC+13, Gabriela Sicilia wrote:
> Hello, I need to generate three random correlated variables: corr (x1,x2 )= -0,9; corr (x1,x3)= 0.9 and corr (x2, x3) =0.

That pattern of correlations is impossible.  With the specified x1/x2 and x1/x3 correlations, the x2/x3 correlation must be negative.

>In addition, x1 and x1 are uniform (a,b) distributed and x2 is a normal (mu, sigma) distributed variable. 
As others have mentioned, there are various ways of producing correlations when some of the marginals are not normal.  At the  link below is a program that can be used to generate correlated non-normal random variables in a few different ways (described in its documentation).  Sorry this is not matlab code, but you could use it to generate the values externally and then read them into matlab.

http://psy.otago.ac.nz/miller/progs/randgen.zip

Of course, first you must select a correlation matrix that is possible.