Simulate sign errors: constant probabilities
Let us simulate our math problems and sign errors.
Here, we will assume that the math problem has just 3 steps, and each step has the same probability of a sign switch. We will simulate the completion of the problem with:
- a 0.10 probability of making a sign switch on each step.
- a 0.45 probability of making a sign switch on each step.
This exercise is part of the course
Probability Puzzles in R
Exercise instructions
- Simulate 10000 iterations of completion of the 3 step math problem, with a 0.10 probability of a sign switch on each step.
- Estimate the probability of arriving at the correct answer, by finding the proportion of the time that an even number of sign switches were made.
- Repeat for a 0.45 probability of a sign switch on each step.
- Estimate the probability of obtaining the correct answer for this second probability.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
set.seed(1)
# Run 10000 iterations, 0.1 sign switch probability
switch_a <-
# Calculate probability of correct answer
# Run 10000 iterations, 0.45 sign switch probability
switch_b <-
# Calculate probability of correct answer