How to create a random Bernoulli matrix ?
古いコメントを表示
I want to create a 256x256 random Bernoulli matrix, how to do that in matlab ?
1 件のコメント
Bilal Siddiqui
2018 年 10 月 2 日
It's simple. A Bernoulli trial produces one of only two outcomes (say 0 or 1). You can use binord. For example p=0.2; n=256; A=binornd(1,p*ones(n));
produces an nxn array of Bernoulli trials which are either 0 or 1 in each outcome. Hope this answers your question.
採用された回答
その他の回答 (2 件)
Byron McMullen
2021 年 2 月 15 日
3 投票
I use this.
bernoulli_matrix = randsrc(rows,cols,[-1,1]);
1 件のコメント
Weijian Liu
2022 年 6 月 4 日
In my opinion, this is the best one.
Bilal Siddiqui
2018 年 10 月 2 日
1 投票
It's simple. A Bernoulli trial produces one of only two outcomes (say 0 or 1). You can use binord. For example p=0.2; n=256; A=binornd(1,p*ones(n));
produces an 256x256 array of Bernoulli trials which are either 0 or 1 in each outcome. Hope this answers your question.
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!