I am trying to find the minimum number of people with a sampled birthday in r of 0.9 (90%)
I am trying to do this through sampling and two for loops:
my expected results are around 300 people I think
bus = 2
#start person count at 2
count = 0
# create counter to count birthdays equal to jan first#assume no february 29th leap year
for (i in 1:400){
sims = 1000
for (i in 1:sims) {
bday = sample(1:365, bus, replace = TRUE) #randomly sample birthdays, producing bus number of samples
if (bday == 1) { # to see if there are two identical birthdays add to counter
count= count + 1
}
}
p= count/sims
print(p)
if(p<0.9){bus = bus+1}
if (p >= 0.9){bus = bus}
}
print(bus)