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!