Blog of Andrés Aravena
CMB2:

Homework 9

26 April 2019. Deadline: Friday, 3 May, 9:00.

Please download the file homework9.R and write your results there. Send the your answers to my mailbox.

1. How many persons with epilepsy in our course?

According to the slides, the proportion of epilepsy on the population is 1%. If you take a group of M people, what is the relative frequency of epilepsy on the group?

Write a function to simulate a group of M people. The function must return the (random) number of people with epilepsy on that group

epilepsy <- function(M) {
    # your code here
}

Simulate N=1E4 times for different values of M. For example, you can take M from the vector seq(from=10, to=90, by=10). Then you can make a plot like this:

2. Birthdays on the same day

What is the chance that two people in our class share the same birthday?

Write a function to simulate a group of M people. The function must return TRUE if there are at least 2 persons with the same birthday

same_birthday <- function(M) {
    # your code here
}

Simulate N=1E4 times for different values of M. For example, you can take M from the vector seq(from=10, to=90, by=10). For each simulation, calculate the proportion of TRUE cases, and store it in a vector. Then you can make a plot like this:

3. Travel time

Ali lives in the Anatolian side of Istanbul. To get to the university, he has to take dolmuş, ferry and tramway. There is a dolmuş every 5 minutes, so Ali has to wait in the corner between 0 and 5 minutes, depending on his luck. Dolmuş takes between 10 and 20 minutes to reach the destination. Then Ali has to wait for the ferry, which departs every 20 minutes and takes between 20 and 30 minutes to reach the European side. Finally, Ali has to wait for the tramway, arriving randomly between 0 and 5 minutes later, and taking 15 to 20 minutes to reach the university.

How long does it take for Ali to get to the university? What is his average time? Can you find an interval of time that covers 90% of the cases?

Deadline: Friday, 3 May, 9:00.