Question

The R command sample (1:365,23, replace=T) >simulates birthdays from a group of 23 people. The expression 2 %int table (sample (1:365, 23, replace=T)) can be used to sim

The R command sample (1:365,23, replace=T) >
simulates birthdays from a group of 23 people. The expression 2 %int table (sample (1:365, 23, replace=T)) can be used to simulate the birthday problem. It creates a frequency table showing how many people have each birthday, and then determines if two is in that table; that is, whether two or more people have the same birthday. Use and suitably modify the expression for the following problems (a) Simulate the probability that two people have the same birthday in a room of 23 people (b) Estimate the number of people needed so that the probability of a match is 95% (e) Find the approximate probability that three people have the same birthday in a room of 50 people (d) Estimate the number of people needed so that the probability that three people have the same birthday is 50%.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) The R code for simulating the 2 people have the same birthday in a room of 23 people is given below:

set.seed(67567)
N <- 1000
n <- 0
for (i in 1:N)
{
X <- sample(1:365, 23, replace = TRUE)
if(2 %in% table(X))
{
n <- n + 1
}
}
n/N

The simulated probability is 0.507 .

b) The R code to estimate the minimum number of people needed so that the probability of match is 95% is given below:
set.seed(67567)
N <- 1000
n <- 0
p <- 0
num_people <- 20
while(p < 0.95)
{
n <- 0
for (i in 1:N)
{
X <- sample(1:365, num_people, replace = TRUE)
if(2 %in% table(X) | 3 %in% table(X) | 4 %in% table(X))
{
n <- n + 1
}
}
num_people = num_people + 1
p = n/N
}
num_people
p

The minimum number of people needed is 47

c)The R code for simulating the 3 people have the same birthday in a room of 50 people is given below:

set.seed(67567)
N <- 1000
n <- 0
for (i in 1:N)
{
X <- sample(1:365, 50, replace = TRUE)
if(3 %in% table(X))
{
n <- n + 1
}
}
n/N

The simulated probability is 0.12

d)The R code to estimate the minimum number of people needed so that three people have the same birthday is 95% is given below:

set.seed(67567)
N <- 1000
n <- 0
p <- 0
num_people <- 20
while(p < 0.5)
{
n <- 0
for (i in 1:N)
{
X <- sample(1:365, num_people, replace = TRUE)
if( 3 %in% table(X) )
{
n <- n + 1
}
}
num_people = num_people + 1
p = n/N
}
num_people
p

The minimum number of people needed is 90

Add a comment
Know the answer?
Add Answer to:
The R command sample (1:365,23, replace=T) > simulates birthdays from a group of 23 people. The...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • We have seen that the probability that at least two people in a group of 23...

    We have seen that the probability that at least two people in a group of 23 people share the same birthday is approximately 0.5. In this question we are interested in the probability that at least three people in a group of 23 people share the same birthday. Draw 23 numbers independently from the integers {1, 2, . . . , 365} with each number equally likely to be drawn. Let E be the event that at least one of...

  • The birthday problem is as follows: given a group of n people in a room, what...

    The birthday problem is as follows: given a group of n people in a room, what is the probability that two or more of them have the same birthday? It is possible to determine the answer to this question via simulation. Using the starting template provided to you, complete the function called calc birthday probability that takes as input n and returns the probability that two or more of the n people will have the same birthday. To do this,...

  • -11 points BBUnderStat12 1.2.016. O Ask Your T Suppose there are 30 people at a party....

    -11 points BBUnderStat12 1.2.016. O Ask Your T Suppose there are 30 people at a party. Do you think any two share the same birthday? Let's use the random-number table to simulate the birthdays of the 30 people at the party Ignoring leap year, let's assume that the year has 365 days. Number the days, with 1 representing January 1, 2 representing January 2, and so forth, with 365 representing December 31. Draw a random sample of 30 days (with...

  • in python The birthday paradox says that the probability that two people in a room will...

    in python The birthday paradox says that the probability that two people in a room will have the same birthday is more than half, provided n, the number of people in the room, is more than 23. This property is not really a paradox, but many people find it surprising. Design a Python program that can test this paradox by a series of experiments on randomly generated birthdays, which test this paradox for n = 5, 6, 7, ..., 50....

  • 5.36. (a) In a group of 23 strangers, what is the probability that at least two of bout if there ...

    5.36. (a) In a group of 23 strangers, what is the probability that at least two of bout if there are 40 strangers? In a group them have the same birthday? How a of 200 strangers, what is the probability that one of them has the same birthday as your birthday? (Hint. See the discussion in Sect. 5.4.1.) (b) Suppose that there are N days in a year (where N could be any number) and that there are n people....

  • State the number of friends (or connections) that you have on Facebook (or Linkedin). In case...

    State the number of friends (or connections) that you have on Facebook (or Linkedin). In case you have more than 365 friends or connections, think of an alternative, smaller group of friends or relatives. What is the chance that there are at least 2 people among your friends (or connections) with the same birthday (same day, not same year)? Let's find out. Please respond with an estimate of the probability that this will happen. This estimate can be intuitive or...

  • (1 point) The sample size needed to estimate the difference between two population proportions to within...

    (1 point) The sample size needed to estimate the difference between two population proportions to within a margin of error E with a significance level of α can be found as follows. In the expression E=z∗p1(1−p1)n1+p2(1−p2)n2‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾√ we replace both n1 and n2 by n (assuming that both samples have the same size) and replace each of p1, and p2, by 0.5 (because their values are not known). Then we solve for n, and get n=(z∗)22E2. Finally, increase the value of...

  • the sample size should include __ men and __women? 9.1.23-T Assigned Media Question Help Use the...

    the sample size should include __ men and __women? 9.1.23-T Assigned Media Question Help Use the expression in the accompanying discussion of sample size to find the size of each sample if you want to estimate the diference between proportions of men and women who own smartphones. Assume that you want 99 % confidence that your error is no more than 0.06 Click the icon to view the discussion of sample size The sample should indlude men and women (Type...

  • 2. Table 1 below shows data from a survey of a random sample of people in the United States in November of 2016 (the Current Population Survey). You arc asked to do a two-sided hypothcsis test to tes...

    2. Table 1 below shows data from a survey of a random sample of people in the United States in November of 2016 (the Current Population Survey). You arc asked to do a two-sided hypothcsis test to test the null hypothesis Put another way Wherc pv21 is the probability that a randomly chosen 21 year old votes and p.25 1s the proba- pv.21-pu ,25 bility that a randomly chosen 25 year old votes a) If you assume the null hypothesis...

  • This Question: 1 pt Question Help samples are drewn from two different populations. The frst sample...

    This Question: 1 pt Question Help samples are drewn from two different populations. The frst sample consists of 30 people with 15 having a common attribute. The Two different simple random samples are drawn from two dift second sample consists of 2000 people with 1416 of them having the same common attribute. Compare the reaul significance level) and a 95% confidence interval estimate of pi-p2 What are the null and alternative hypotheses for the hypothesis test? H1 P1 P2 Identify...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT