Search tips

Search tips

# Discussion Groups | Matlab DSP | how to make random binary bits!?

Technical discussion about Matlab and issues related to Digital Signal Processing.

Is this thread worth a thumbs up?

0

# how to make random binary bits!? - scguc - Dec 10 11:45:00 2005

how to make random binary bits with probability 0.5 for both zeros and
ones!?

# Re: how to make random binary bits!? - Nandan Das - Dec 12 12:42:00 2005

take samples from a uniform [0,1] distribution (using rand), and then set =
0 if less than 0.5 and 1 if greater than 0.5 (using round).

Nandan

On 12/10/05, scguc <scguc@scgu...> wrote:
>
> how to make random binary bits with probability 0.5 for both zeros and
> ones!?

# Re: how to make random binary bits!? - arkkimede - Dec 13 9:27:00 2005

bit = round(rand(1,nBit))

2005/12/10, scguc <scguc@scgu...>:
>
> how to make random binary bits with probability 0.5 for both zeros and
> ones!?

# Re: how to make random binary bits!? - Amit Pathania - Dec 14 13:59:00 2005

also

bits = randn(1,nBits)<0;

this would give you the bits as an array of logicals
--- arkkimede <arkkimede@arkk...> wrote:

> bit == round(rand(1,nBit))
>
> 2005/12/10, scguc <scguc@scgu...>:
> >
> > how to make random binary bits with probability 0.5 for both zeros and
> > ones!?
>

# Re: how to make random binary bits!? - Tahmina Ajmal - Dec 15 17:27:00 2005

also
randint(M, N, [0 1]) generates random numbers matrix of size MxN in the range 0 and 1 with equal probability.