Question

Use R to tackle the following problem Suppose there is a class of 23 people with...

Use R to tackle the following problem

Suppose there is a class of 23 people with birthdays given by the random variables X1, . . . , X23. Suppose that the random variables are independent and that each Xi has the property that P(Xi = k) = 1 365 for 1 ≤ k ≤ 365; thus we make the assumption that there are no leap years and that people are equally likely to be born on each day of the year. By running simulations, estimate the probability that no two people have the same birthday

Homework Answers

Answer #1

We will use the folowing steps to simulate

  1. Generate 23 random draws from uniform distribution in (0,1). These are
  2. For each set , k being the day of the year (k is in the interval [1,365]) , if . For example if then we know that . The next integer is 201. Hence the birthday of 1st person is
  3. After having generated the values of we check if any 2 numbers are the same. If no two numbers are the same then we know that in this trial no two people have the same birthday and we set y=1 otherwise we set y=0
  4. We perform step 1 to 3 N number of times. The probability that no two people have the same brithday is (Number of times y=1)/N

The therorectical probability that no two people have the same birthday

Now the R code (all statements starting with # are coments)

The output is

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT