制作具有固定概率为零的随机二进制矩阵

Making a random binary matrix with fixed probability of zeros

我没有通讯工具箱,也不想为此付费,所以无法使用 randsrc 功能。 0 出现的概率应为 0.2,1 出现的概率应为 0.8。

x = rand(1 100)
A = rand(1,100); % uniform distributed between 0 and 1
B = A>=0.2; % Makes the lowest 20% values 0, the rest 1