# Simulating probability of choosing the right answer

I have 20 students, 1000 questions with five options a, b, c, d, e. First, I am using rmultinom(1000,1,c(0.2,0.2,0.2,0.2,0.2) to generate the truth. Next, I want to simulate what a student chooses for each question.

Suppose for Q1, the correct answer is a, I need to simulate the probability of student 1 of choosing the correct answer to be higher than the truth. And then let the choice be uniform for the other 4 choices.

Which probability function should I use to simulate the answers?

• Are you sure you want to use multinomial rather then categorical distribution..? – Tim Aug 22 '16 at 21:45
• Questions solely about how software works are off-topic here, but you may have a real statistical question buried here. You may want to edit your question to clarify the underlying statistical issue. You may find that when you understand the statistical concepts involved, the software-specific elements are self-evident or at least easy to get from the documentation. – gung - Reinstate Monica Aug 22 '16 at 22:00
• Can you say more about your situation, & your goals? What are you ultimately trying to do & why? People don't usually simulate data one student at a time, eg. – gung - Reinstate Monica Aug 22 '16 at 22:06
• @Tim I see I can use categorical distribution to specify the probability of one of those answers. But, I want to simulate the probability of getting each of those answers. Do you think categorical distribution is better? – amrapaliz Aug 22 '16 at 22:06
• This question is obviously a statistical question: What is a reasonable specification for distribution of responses (answers) for an individual? How is this a software question??? – not_bonferroni Aug 22 '16 at 22:06

You have $k$ distinct outcomes, where each can be sampled with some probability. This means that we are talking about categorical distribution that is parametrized by vector of probabilities $\boldsymbol{p} = (p_1,\dots,p_k)$. In your case you want to sample the "correct" answer with probability $\alpha$ and rest of the answers uniformly each with probability $\frac{1-\alpha}{k-1}$. The only question you need to ask yourself is how much likely should the "correct" answer be selected. If it's $1/k$ then you sample all the answers uniformly, if it's greater than you make it more likely. In R you can simulate values from categorical distribution using sample.int(k, n, p, replace = TRUE) where k is the number of categories, n is sample size and p is vector of probabilities, or rcat function from extraDistr package.
• Thank you @Tim, this is very clear and helpful. I can simulate the categorical distribution now outcomes <- sample(answers, 100, replace=TRUE prob=c(0.1, 0.2, 0.65, 0.05, 0.1)) & then I can get the probability of each answer too. Yes, you are right that it is unlikely that there is uniformity in the answers and that's exactly what I am trying to simulate. – amrapaliz Aug 22 '16 at 22:39