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일

0 개 추천

Yes, this code is correct for the case n=1.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기

태그

질문:

2020년 10월 14일

댓글:

2020년 10월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by