randsample([0 1],1,true,[1 - p p]) ..... with p as a vector?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have the following code that generates a 0 or a 1 depending on the probability p:
randsample([0 1],1,true,[1 - p p])
But suppose my probability was taken from a vector of other probabilities. Is it possible to ammend my code to handle all probabilities at once, rather than looping through the vector for each probability?
2 Kommentare
Rik
am 29 Nov. 2018
I don't understand your question, nor do I have the toolbox for this function, so I can't play around with it for you.
Antworten (2)
Walter Roberson
am 29 Nov. 2018
Bearbeitet: Walter Roberson
am 29 Nov. 2018
double( rand(size(p)) < p )
0 Kommentare
Siehe auch
Kategorien
Mehr zu Biomedical Imaging finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!