poster
2019-12-10, 20:30
生成数量为N的,大小为N的随机二进制向量的数量为X的最佳方法是什么?浓度为1s(或者模拟为0s),范围从非常低到非常高?
使用randint或unidrnd(如本问题所示 (https://stackoverflow.com/questions/2442141/uniform-distribution-of-binary-values-in-matlab) )将生成具有均匀分布的二进制矢量,在这种情况下,这不是我所需要的。
任何帮助表示赞赏!
回答:
Laserallan (https://stackoverflow.com/questions/2549339/matlab-binary-vector-with-high-concentration-of-1s-or-0s/2549370#2549370)的方法是必经之路。
对于具有10个元素和70%随机分布的向量,您可以编写
randVec = rand(10,1)
使用randint或unidrnd(如本问题所示 (https://stackoverflow.com/questions/2442141/uniform-distribution-of-binary-values-in-matlab) )将生成具有均匀分布的二进制矢量,在这种情况下,这不是我所需要的。
任何帮助表示赞赏!
回答:
Laserallan (https://stackoverflow.com/questions/2549339/matlab-binary-vector-with-high-concentration-of-1s-or-0s/2549370#2549370)的方法是必经之路。
对于具有10个元素和70%随机分布的向量,您可以编写
randVec = rand(10,1)