Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Random -1's and 1's
Date: Sat, 3 Sep 2011 13:34:11 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 9
Message-ID: <j3tacj$75k$1@newscl01ah.mathworks.com>
References: <j3t81j$rd$1@newscl01ah.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1315056851 7348 172.30.248.35 (3 Sep 2011 13:34:11 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 3 Sep 2011 13:34:11 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:742134

"Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <j3t81j$rd$1@newscl01ah.mathworks.com>...
> Hi Everyone,
> 
> What is the most efficient way of creating a vector filled with -1's and 1's, with probability(-1) = probability(1)?
> 

 v = 2*(rand(1,100) < 0.5) - 1

Bruno