How to create a random Bernoulli matrix ?
Mostra commenti meno recenti
I want to create a 256x256 random Bernoulli matrix, how to do that in matlab ?
1 Commento
Bilal Siddiqui
il 2 Ott 2018
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.
Risposta accettata
Più risposte (2)
Byron McMullen
il 15 Feb 2021
3 voti
I use this.
bernoulli_matrix = randsrc(rows,cols,[-1,1]);
1 Commento
Weijian Liu
il 4 Giu 2022
In my opinion, this is the best one.
Bilal Siddiqui
il 2 Ott 2018
1 voto
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.
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!