Uniform distribution of binary values in Matlab
Posted
by JohnIdol
on Stack Overflow
See other posts from Stack Overflow
or by JohnIdol
Published on 2010-03-14T12:36:23Z
Indexed on
2010/03/14
12:45 UTC
Read the original article
Hit count: 230
I have a requirement for the generation of a given number N of vectors of given size each consistent of a uniform distribution of 0s and 1s.
This is what I am doing at the moment, but I noticed that the distribution is strongly peaked at half 1s and half 0s, which is no good for what I am doing:
a = randint(1, sizeOfVector, [0 1]);
The unifrnd
function looks promising for what I need, but I can't manage to understand how to output a binary vector of that size.
Is it the case that I can use the unifrnd
function (and if so how would be appreciated!) or can is there any other more convenient way to obtain such a set of vectors?
Any help appreciated!
© Stack Overflow or respective owner