Generate A Sequence of 25 Independent Bernoulli RVs with p = .8?
Afficher commentaires plus anciens
I have a question that asks me to generate a sequence of 25 independent Bernoulli RVs where p = .8. I want to see how many random numbers are needed to achieve this.
Here's what I have gathered so far ...
X = rand(1); Y = ( X <= p ); % Will generate Y = 0 if false, Y = 1 if true.
I want to create a vector with all of the Y values of 0s and 1s and have the program terminate after 25 1's have been generated. Then I want to find out the length of the entire vector with 0's and 1's.
Any help you can provide me would be GREATLY appreciated!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!