simple bernoulli sampler function

1 Ansicht (letzte 30 Tage)
Michal
Michal am 14 Okt. 2020
Kommentiert: Michal am 15 Okt. 2020
I am trying to find replacement of binornd function by standard MATLAB code. Is the following command
r = binornd(1,p,sz)
exactly equivalent to the:
function r = randb(p,sz)
% simple bernoulli sampler
r = double(rand(sz) < p);
end
If not, what is the correct equivalent?

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 14 Okt. 2020
Yes, this code is correct for the case n=1.

Weitere Antworten (0)

Kategorien

Mehr zu Descriptive Statistics and Visualization finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by