How to generate a Bernoulli distributed binary data

조회 수: 5 (최근 30일)
Mallikarjuna
Mallikarjuna 2013년 7월 1일
Hi, I am trying to generate a Bernoulli distributed binary data. please help.

답변 (2개)

Shashank Prasanna
Shashank Prasanna 2013년 7월 2일
You probably have an older version of MATLAB installed.
Try the following instead:
Check the output of 'ver' command to confirm you have the statistics toolbox.
If not there is always FEX:

Wayne King
Wayne King 2013년 7월 1일
편집: Wayne King 2013년 7월 1일
Do you have the Statistics Toolbox?
You have to specify the parameter for the distribution, which is the probability of a "success". Here I'll use p = 0.25
pd = makedist('Binomial','N',1,'p',0.25);
x = random(pd,100,1);
If you want the simple case where p = 0.5
x = randi([0 1],100,1);
  댓글 수: 1
Mallikarjuna
Mallikarjuna 2013년 7월 2일
I am getting an error saying, 'makedist function is not supported'! Is there any other way of doing it without using the statistics toolbox?

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by