prisoners: 100 prisoners problem

Description Usage Arguments Details Value Examples

Description

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:

Usage

1
prisoners(sims, pris = 100, trys = 0.5)

Arguments

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.

Details

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.

Value

A rational approximation of the probability that a the group of prisoners will find each of their own numbers.

Examples

1
prisoners(1000)

benjcunningham/rcarlo documentation built on May 12, 2019, 11:56 a.m.