How do I simulate Bernoulli observations?
5 ビュー (過去 30 日間)
古いコメントを表示
I want to simulate 1000 Bernoulli observations with p = 0.2 and compute an MLE estimate of p along with standard errors and t-statistics, what's the easiest way to do so?
0 件のコメント
回答 (1 件)
Prachi Kulkarni
2021 年 10 月 18 日
Hi,
You can generate the Bernoulli observation and get the statistics as follows.
n = 1000;
p = 0.2;
data = binornd(1,p,n,1); % Generate 1000 observatiosn of Bernoulli Trials with p = 0.2
phat = mle(data,Distribution="Bernoulli"); % Maximum Likelihood Estimate of p
se = std(data)/sqrt(n); % Standard Error of Mean
[hypothesis,pvalue,ci,stats] = ttest(data); % t-statistics
For more information, see the following documentation.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Conditional Mean Models についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!