simple bernoulli sampler function

조회 수: 5 (최근 30일)
Michal
Michal 2020년 10월 14일
댓글: Michal 2020년 10월 15일
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?

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 10월 14일
Yes, this code is correct for the case n=1.

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by