Generate A Sequence of 25 Independent Bernoulli RVs with p = .8?
Mostrar comentarios más antiguos
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!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!