Description Usage Arguments Details Value Examples
This function simulates the probability that a group of 100 prisoners are able to find each of their own numbers in one of 100 drawers by following this algorithm:
1 | prisoners(sims, pris = 100, trys = 0.5)
|
sims |
The number of survival situations to simulate. |
pris |
The number of prisoners. |
trys |
The ratio of attempts each prisoner gets relative to the number of drawers. |
1. A prisoner first opens the drawer with her own number. 2. If the drawer contains her number, she is finished. 3. Otherwise, the drawer contains another number and the prisoner opens the drawer with that number next. 4. The prisoner repeats steps 2 and 3 until she finds her number or has opened n / 2 drawers.
The problem was first proposed by Peter Bro Miltersen.
A rational approximation of the probability that a the group of prisoners will find each of their own numbers.
1 | prisoners(1000)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.