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

bdays<- sample.int(365,n,replace=TRUE) uniqBdays<- length(unique(bdays)) return(

ID: 3325423 • Letter: B

Question

bdays<- sample.int(365,n,replace=TRUE) uniqBdays<- length(unique(bdays)) return(uniqBdays) } But! I can’t figure out how to write the code using the function “replicate” for Part b) so that the output can be used to approximate the probability that there is at least one matching, for Part c). [the code needs to be for R Studio, No For Loop] O iaucies. 11.3 (Birthday problem). Suppose you have a class of n students and you're interested in the probability that at least two students in the class share the same birthday. If one assumes that each birthday is equally likely from the set (1, 2, ., 365), then collecting birthdays can be viewed as a a. Write a function with argument n that samples n birthdays and computes b. Using the replicate function, repeat this simulation 1000 times for the c. From the output, approximate the probability that there is at least one sample of size n chosen with replacement from the set. the number of unique birthdays observed. special case of n = 30 students. matching birthday among the 30 birthdays.

Explanation / Answer

Ans.