Path: news.mathworks.com!not-for-mail
From: "Ulrik Nash" <uwn@sam.sdu.dk>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Random -1's and 1's
Date: Sat, 3 Sep 2011 13:54:10 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 12
Message-ID: <j3tbi2$abd$1@newscl01ah.mathworks.com>
References: <j3t81j$rd$1@newscl01ah.mathworks.com> <j3tacj$75k$1@newscl01ah.mathworks.com>
Reply-To: "Ulrik Nash" <uwn@sam.sdu.dk>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1315058050 10605 172.30.248.47 (3 Sep 2011 13:54:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 3 Sep 2011 13:54:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2106050
Xref: news.mathworks.com comp.soft-sys.matlab:742136

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <j3tacj$75k$1@newscl01ah.mathworks.com>...
> "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

Thank you both. I think I will go with Bruno's idea. Very neat!