Blog of Andrés Aravena
CMB2:

# Homework 9

07 June 2021. Deadline: Friday, 11 June, 9:00.

# Wedding Planner

You got a new job as “Wedding Planner”. Your clients want to organize a big party, but they are not sure how many people will attend. Talking to your clients, you find that they have:

• 10 good friends that will probably attend to the party,
• 50 regular friends that may or may not attend, and
• 40 acquittances (i.e. people they know but that are not really friends) that must be invited but that will probably not attend

Each one of the good friends will attend with probability 90%. The regular friends will attend with probability 50%. The acquittances will attend with probability 20%.

## 1. Simulate one party

The function party receives the number of good, regular and bad friends, and returns the total number of people attending to the simulated party.

party <- function(n_good, n_regular, n_bad) {
}

If all is right, you should get something like this:

party(10, 50, 40)
[1] 48

## 2. Simulate ten thousand parties

Store the result in a vector called parties, and make a bar plot

# write your code here
barplot(table(parties))

## 3. Mean value and standard deviation

Find the average and the standard deviation of the number of people attending the party

# write your code here
[1] 42.0306

[1] 4.415225

## 4. Find an interval containing 95% of all parties

This will allow you to have a reasonable idea of what will happen in real life.

You should get something like this

[1] 33.20015 50.86105
# write your code here

## 5. Find population mean using a small sample

In a previous question we found the mean value of parties, assuming that we know all of them.

Now we will assume that the vector parties is a population, and we have only access to a small sample of 3 cases.

sample_of_3 <- sample(parties, size=3)

Please find an interval containing the population mean with 95% confidence

[1] 33.74417 48.92250

Attention: this question is different from the previous one. Here we ask for an interval for the population mean, not for the individual cases.

## 6. Find population mean using a larger sample

Repeat the same procedure as before, assuming that you have a sample of 20 cases.

sample_of_20 <- sample(parties, size=20)

Please find an interval containing the population mean with 95% confidence

[1] 39.13881 43.52786