How to generate random number from Bernoulli distribution?
41 views (last 30 days)
Show older comments
just like the below command
a=randn(1,1000)
how can we generate random number from bernoulli distribution
0 Comments
Accepted Answer
Bruno Luong
on 19 Jan 2023
p = 0.25
X = double(rand(1,1000) < p)
histogram(X,'Normalization','pdf')
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!