simple bernoulli sampler function

2 ビュー (過去 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.
  1 件のコメント
Michal
Michal 2020 年 10 月 15 日
Well OK ... thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics and Visualization についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by