I need to make a set of 2000 random numbers between 0 and 1, with a mean of 0.5, with most of the numbers being either high or low (bimodal distrubution with peaks at 0 and 1)
Show older comments
Basically what the question says. It should look something like this

Though the left side doesn't need to have a higher peak or anything.
Flat distributions are easy - but how do I go about making a vector with 2000 numbers with this type of distribution?
Accepted Answer
More Answers (1)
jgg
on 24 Feb 2016
m = randi([0,1],2000,1);
r = abs(randn(2000,1));
r = r - min(r);
r = r./max(r);
num = m;
num(m==0) = 0 + r(m==0);
num(m==1) = 1 - r(m==1);
Something like this should do it, since you don`t really care how they are generated. Basically, generate your integers (0,1) then just add some noise. This is truncated Gaussian noise.
Categories
Find more on Univariate Discrete Distributions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!