simple bernoulli sampler function

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 个)

类别

帮助中心File 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