I am trying to generate a random sequence of 0s and 1s such that any time a sequence is generated, the probability of 1 is 0.3. I tried the following in Matlab
%%clear all; %%close all;clc; %%(rand(1,10)<=0.3)
The problem is that every time I run this, I get a different proportion of 1s.
Can anyone suggest a better approach?
If you want to have exactely a propotion of 0.3 at the end, you can do:
Basically, it creates an array with a
0.3proportion of1.Then, it permutes it randomly.