simple bernoulli sampler function

1 visualización (últimos 30 días)
Michal
Michal el 14 de Oct. de 2020
Comentada: Michal el 15 de Oct. de 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?

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 14 de Oct. de 2020
Yes, this code is correct for the case n=1.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by