programming the number of steps till every element of a set appears
Mostrar comentarios más antiguos
I need to write a program that simulates the following experiment.
I have a set of N cards to collect, and at each stage of the experiment a random card is selected with an equal probability of any card, even if the card had been selected before. I then want to record the number of steps taken for every card to appear.
Eg. say that N=5, it would generate a sequence of steps, such as 5 3 4 3 5 1 3 4 3 2 randomly. Then record the steps taken till every number has appeared. In this case 10 steps.
Respuestas (1)
Jos (10584)
el 18 de Feb. de 2018
0 votos
What have you tried so far, perhaps in writing some pseudocode, or making a flowchart?
randi and while are functions that you will find useful.
And to keep track of the drawn cards, create a logical matrix S , initialise it to false, and use the function all to see if there are still undrawn cards.
Enough tips for the day ...
Categorías
Más información sobre Card games 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!