How to estimate the probability of a certain number of students with cohorts using R?

I'm trying to calculate the probability of this task. In a class a teacher marks for every 9 exam scripts, he makes up a grade for the tenth student, not reading it at all. The external examiner checks a random sample of exams equal to the rounded up square root of the number of people on the module. The examiner will identify an unmarked exam correctly 94% of the time, and will identify a marked exam as unmarked 0% of the time. Write a program that will estimate the probability of the teacher getting caught given a certain number of students. Test it with cohorts of 40, 80 and 160.

#This is my code: n = 10 x = 160 ntrials = 1000 trials = rep(0,ntrials) for (j in 1:ntrials) { y = sample(x,n) } mean(trials)

How should I calculate the probability! Kindly help me. TIA

Hi, welcome!

Please have a look to our homework policy, homework inspired questions are welcome but they should not include verbatim instructions from your course.

I suggest you try to solve this without R first.

I would start with trying this on a single exam first.

P(gets caught on a single exam) = P(gets caught from unmarked exam) + P(gets caught from marked exam) = P(chooses unmarked)*P(unmarked & caught) + P(chooses marked)*P(marked & caught). (I'm not sure that sentence is correct.)

Once you have P(gets caught on a single exam), then I think it is a binomial distribution problem of P(getting caught at least once in n trials).

If the above is correct without R, then you have an approach for coding in R.