simple bernoulli sampler function

1 vue (au cours des 30 derniers jours)
Michal
Michal le 14 Oct 2020
Commenté : Michal le 15 Oct 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?

Réponse acceptée

Ameer Hamza
Ameer Hamza le 14 Oct 2020
Yes, this code is correct for the case n=1.
  1 commentaire
Michal
Michal le 15 Oct 2020
Well OK ... thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by