simple bernoulli sampler function

조회 수: 1 (최근 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개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by