You are on page 1of 3

PARTHASARATHI BERA.

2021H1540811P P1 group

Activity1:

Finding the largest number: The following problem, known originally as the secretary
problem, was first introduced by Martin Gardner in his Mathematical Games column in
Scientific American. It was originally cast in terms of a manager trying to hire the most
qualified secretary from a group of ‘n’ applicants. Versions include finding the best lottery
prize among ‘n’ prizes, and the following game to find the highest number in a list of ‘n’
numbers.

On ‘n’ pieces of paper are written ‘n’ distinct numbers. Let ‘z’ be the largest number
in the group. You will be shown the pieces of paper one at a time and you must decide after
each number whether to choose that number—and the game stops—or reject it and move
on to the next number. Your goal is to find ‘z’. When shown the kth number, the only
information you are given is the relative rank of that number compared to the previous k − 1
numbers. What should your strategy be for deciding which number to choose? And using
such a strategy what is the probability of getting the top number?

#R
# Numbers shortlisted from 1, ..., n
No of trials <- 10000
n1 <- 100
r <- round(n/exp(1)) r = n/e = 37
simlist <- numeric(ntrials)
> for (j in 1: n1)
{
numbers <- sample(1:n, n)
best <- which(numbers==n) # position of top number
prob <- 0
firstmax <- max(numbers[1:r]) # largest of first r
for (i in (r+1) : n)
{ # look after r-th number
if (numbers[i] > firstmax)
{
if (numbers[i] == n) prob <- 1
break
}
else {prob<-0} }
simlist[j] <- prob }

> mean(simlist)
0.3749
Activity2:

According to Leder et al. (2002), many airlines consistently report that about 12% of all
booked passengers do not show up to the gate due to cancellations and no-shows. If an
airline sells 110 tickets for a flight that seats 100 passengers, what is the probability that the
airline overbooked (sold more tickets than seats)?

For a 100-seat flight, suppose the airline would like to sell the maximum number of tickets
such that the chance of overbooking is less than 5%. The airlines call this a “5% bump
threshold” overbooking strategy. How many tickets should the airline sell?

Simulate the probability of overbooking when 108 tickets are sold.

To simulate the probability of overbooking when 108 tickets are sold, we could
approach the problem in one of two ways: (i) generate 108 Bernoulli random
variables with p = 0.88 or (ii) generate a single Binomial random variable with
n = 108 and p = 0.88. Now that we have the Binomial framework, it is more
convenient to use.

> rbinom(1, 108, 0.88)


> if(rbinom(1, 108, 0.88) > 100) 1 else 0
> simlist <- replicate(10000,
if (rbinom(1, 108, 0.88) > 100) 1 else 0)
> mean(simlist)
[1] 0.0421

Activity3:
The number of accidents per month at a busy intersection has a Poisson distribution with
parameter λ = 7.5. Conditions at the intersection have not changed much over time. Suppose
each accident costs local government about $25,000 for clean-up. How much do accidents
cost, on average, over a year’s time?

> accidents <- rpois(12,7.5)


> cost <- sum(25000*accidents)
> cost
[1] 2200000
> simlist <- replicate (1000, sum(25000*rpois(12,7.5)))
> mean(simlist)

[1] 2258725

You might also like