Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The R command > sample (1l:365,23,replace=T) simulates birthdays from a group of

ID: 3241635 • Letter: T

Question

The R command

> sample (1l:365,23,replace=T)

simulates birthdays from a group of 23 people. The expression

> 2 %in% table(sample(1:365,23,replace=T))

can be used to simulate the birthday problem (probability of two people in a group

of 23 with the same birthday).

Use and suitably modify this expression for the following problems:

(a) Simulate the probability that two people have the same birthday in a room of 23

people

(b) Find the number of people needed so that the probability of a match is 95%

(c) 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%

NOTE: I'M NEW TO R SOFTWARE. I AM SURE THERE ARE MULTIPLE WAYS TO SOL VE

THESE SIMPLE PROBLEMS BUT I'M LOOKING FOR A SOLUTION THAT USES THE

ABOVE EXPRESSION OR A VERSION OF IT. THANKS

Explanation / Answer

library(gtools)
probability<-function(r){
return(1-(permutations(n=365,r)/365^r))}
probability(25)

r<-80

repeat {
print (r)
r = r-1
if (probability(r) == 95){
break
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote