Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Generate random sequence of 1's and -1's in matlab

Status
Not open for further replies.

Chinmaye

Full Member level 3
Joined
Jan 18, 2016
Messages
164
Helped
0
Reputation
0
Reaction score
1
Trophy points
1,298
Activity points
3,145
How do i generate a random sequence of 1's and minus -1's in matlab with mean 0?
 

This doesnt always give a mean of zero
 

Re: generate random 1's and -1's in matlab

the rand function generates uniformly distributed random numbers

if you tell it to generate random numbers between 0 and 1,
you can convert those less than 0.5 to -1 and those greater than 0.5 to 1
 

This doesnt always give a mean of zero
By nature of random distribution, an arbitrary selected sample can't have exactly zero mean otherwise it's not random.

You may want to specify additional properties of the random distribution, e.g. maximal imbalance for a given sample length.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top