please how do it generate a binary sequence of o's and 1's of lengtth 2n that occurs with equal probability and are mutually independent using rand function
Show older comments
am new to matlab so am kinda stuck...advice welcomed..thnk u
Answers (2)
Walter Roberson
on 14 Oct 2015
0 votes
1 Comment
Walter Roberson
on 14 Oct 2015
Alternative interpretation:
t = [zeros(1,n), ones(1,n)];
random_result = t(randperm(t));
This would be for the case where the total number of 0 and 1 each had to be exactly n -- but if that is the case then they are not mutually independent.
Guillaume
on 14 Oct 2015
rand(1, 2*n) > 0.5
would fit your requirements I think.
Categories
Find more on Matrix Indexing 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!