I was sent this photo of a blackboard and asked "What is the chance that a random answer will be correct?"
I thought this was an incomplete question but interpreted it as :
Given four occurrences of 3 values, one of which is repeated, such as (A,B,C,A) what are the chances of a random guess being correct?
The random selection is one of the four locations, not one of the three different values.
The correct answer is randomly selected before the guess.
If correct answer is either first A or second A and the random guess likewise then the answer is deemed to be correct whichever A is selected. So if first A is correct then the guess of either A, first or second, are both correct, otherwise the problem is just one of 4 different values and chance of correct guess is 1 in 4 or 25%.
This is equivalent to putting 4 balls into a black bag, two of which are identical (A), and after shaking bag randomly taking one out blindly. This is then the correct answer. This is replaced into the bag, shaken again and another ball selected. If they are the same then it is deemed correct.
Chance of selecting A is 2/4 = 1/2
Chance of selecting B is 1/4
Chance of selecting C is 1/4
Chance of selecting A is 2/4 = 1/2, and so chance of both answer and guess 1/2 x 1/2 = 1/4
Chance of selecting B is 1/4 and so chance of both answer and guess 1/4 x 1/4 = 1/16
Chance of selecting C is 1/4 and so chance of both answer and guess 1/4 x 1/4 = 1/16
Therefore the chance of a random guess being correct for (A,B,C,A) is
1/4 + 1/16 + 1/16 = 3/8 or 37.5%
Total number of choices both correct and incorrect should equal %100.
Chance of selecting A is 2/4 = 1/2, and so chance of answer and wrong guess 1/2 x 1/2 = 1/4
Chance of selecting B is 1/4 and so chance of both answer and wrong guess 1/4 x 3/4 = 3/16
Chance of selecting C is 1/4 and so chance of both answer and wrong guess 1/4 x 3/4 = 3/16
Therefore the chance of a random guess being incorrect for (A,B,C,A) is
1/4 + 3/16 + 3/16 = 5/8 or 62.5%
therefore total of all solutions = 62.5% + 37.5% = 100%.
Consider same approach with 4 different values (A,B,C,D).
Each ball has a 1/4 chance of being selected as correct and then a 1/4 chance of being selected again. This has a 1/16 chance (1/4 x1/4) of happening. There are 4 balls so total chance of correct guess is 4 x 1/16 = 1/4 or 25%.
This is as expected. Also chance of incorrect answer is 4 x 1/4 x 3/16 = 3/4 or 75% again making total of all solutions 100%.
Python program.
I wrote a simple python program to model this solution and its output for 5000 trials is reproduced below.
# Program to calculate chance of success of correctly choosing when randomly selecting from collection of items
import random
print() # add blank line
# alternative values commented out
# values = ['A', 'B', 'C', 'A', 'A']
# expected = 44
# values = ['A', 'B', 'C', 'B', 'A', 'A']
# expected = 38.9
values = ['A', 'B', 'C', 'A']
expected = 37.5
print(" Random guess for ",values)
print()
# Populate the list with values
# values = ['A', 'B', 'C', 'A','A']
count = 0 # number of correct guesses in one run
total = 0
count_total = 0
runs = 10 # number of runs
tests = 500 # number of trials in the run
i1 = i2 = 0 # set while counters to zero
while i1 < runs:
i1 = i1 + 1
i2 = 0 # reset tests while counter
while i2 < tests:
i2 = i2 + 1
# Randomly choose correct value
random_choice_correct = random.choice(values)
# Randomly guess correct value
random_choice_guess = random.choice(values)
total = total + 1
if random_choice_guess == random_choice_correct:
count = count + 1 # add number of correct guesses
print ("Number of correct guesses = ", count, "for ", tests, " runs.", count*100/tests, "%"),
count_total = count_total + count # add correct answers for each run
count = total = 0
print()
print ("Number of ",tests," runs = ", runs)
print()
print ("Average number correct guesses = ", count_total*100/(tests*runs), "% compared to expected ", expected,"%")
Chance of selecting A is 3/5
Chance of selecting B is 1/5
Chance of selecting C is 1/5
Chance of selecting A is 3/5, and so chance of both answer and guess 9/25
Chance of selecting B is 1/5 and so chance of both answer and guess 1/25
Chance of selecting C is 1/5 and so chance of both answer and guess 1/25
Therefore the chance of a random guess being correct for (A,B,C,A,A) is
11/25 or 44.0%
Random guess for ['A', 'B', 'C', 'A', 'A']
Program output
Correct guesses = 234 for 500 runs. 46.8%
Correct guesses = 224 for 500 runs. 44.8%
Correct guesses = 208 for 500 runs. 41.6%
Correct guesses = 234 for 500 runs. 46.8%
Correct guesses = 214 for 500 runs. 42.8%
Correct guesses = 218 for 500 runs. 43.6%
Correct guesses = 215 for 500 runs. 43.0%
Correct guesses = 224 for 500 runs. 44.8%
Correct guesses = 248 for 500 runs. 49.6%
Correct guesses = 206 for 500 runs. 41.2%
Number of 500 runs = 10
Ave. Correct 44.5% expected 44.0%
Chance of selecting A is 3/6
Chance of selecting B is 2/6
Chance of selecting C is 1/6
Chance of selecting A is 3/6, and so chance of both answer and guess 9/36
Chance of selecting B is 2/6 and so chance of both answer and guess 4/36
Chance of selecting C is 1/6 and so chance of both answer and guess 1/36
Therefore the chance of a random guess being correct for (A,B,C,A,A) is
14/36 or 38.9%
Random guess for ['A', 'B', 'C', 'B', 'A', 'A']
Program output
Correct guesses = 193 for 500 runs. 38.6%
Correct guesses = 197 for 500 runs. 39.4%
Correct guesses = 177 for 500 runs. 35.4%
Correct guesses = 215 for 500 runs. 43.0%
Correct guesses = 207 for 500 runs. 41.4%
Correct guesses = 186 for 500 runs. 37.2%
Correct guesses = 194 for 500 runs. 38.8%
Correct guesses = 193 for 500 runs. 38.6%
Correct guesses = 202 for 500 runs. 40.4%
Correct guesses = 175 for 500 runs. 35.0%
Number of 500 runs = 10
Ave. Correct guesses 38.78% expected 38.9%
The correct answer ignores the number of repetitions so all correct answers are chosen from A, B, C for which there is a 1/3 probability.
The probability of guessing the correct answer remains as before. In all cases as demonstrated below the answer was 33.3% and this was verified by program amended to reflect the change of selecting the correct ball.
This surprised me but on further consideration whatever the random guess ball resulted in, A, B or C, this had the same 1/3 chance of being correct. In fact if instead of a random guess always select one, say B, as the guess it will on average be correct 1/3 of the time provided the correct ball is chosen at random from A, B, C.
Imagine there being two black bags, the first with 3 balls A, B, C from which the ball deemed to be correct is chosen, and a second black bag with the collection of balls in it, say A, A, B, C from which to make a guess. Imagine the question reversed, selecting a ball from second bag and then selecting ball from first bag and checking for a match. Whatever ball is taken from second bag will have a 1/3 chance of being selected in first bag.
Chance of selecting A is 1/3
Chance of selecting B is 1/3
Chance of selecting C is 1/3
Chance of selecting A is 2/4, and so chance of both answer and guess 2/12
Chance of selecting B is 1/4 and so chance of both answer and guess 1/12
Chance of selecting C is 1/4 and so chance of both answer and guess 1/12
Therefore the chance of a random guess being correct for (A,B,C,A,A) is
4/12 or 33.3%
Random guess for ['A', 'B', 'C', 'A']
Correct guesses = 164 for 500 runs. 32.8 %
Correct guesses = 157 for 500 runs. 31.4 %
Correct guesses = 149 for 500 runs. 29.8 %
Correct guesses = 165 for 500 runs. 33.0 %
Correct guesses = 167 for 500 runs. 33.4 %
Correct guesses = 171 for 500 runs. 34.2 %
Correct guesses = 184 for 500 runs. 36.8 %
Correct guesses = 162 for 500 runs. 32.4 %
Correct guesses = 183 for 500 runs. 36.6 %
Correct guesses = 175 for 500 runs. 35.0 %
Number of 500 runs = 10
Ave. Correct guesses = 33.54 % expected 33.3 %
Chance of selecting A is 1/3
Chance of selecting B is 1/3
Chance of selecting C is 1/3
Chance of selecting A is 2/5, and so chance of both answer and guess 2/15
Chance of selecting B is 2/5 and so chance of both answer and guess 2/15
Chance of selecting C is 1/5 and so chance of both answer and guess 1/15
Therefore the chance of a random guess being correct for (A,B,C,A,A) is
5/15 or 33.3%
Random guess for ['A', 'B', 'C', 'B', 'A']
Program output
Correct guesses = 193 for 500 runs. 38.6%
Correct guesses = 197 for 500 runs. 39.4%
Correct guesses = 177 for 500 runs. 35.4%
Correct guesses = 215 for 500 runs. 43.0%
Correct guesses = 207 for 500 runs. 41.4%
Correct guesses = 186 for 500 runs. 37.2%
Correct guesses = 194 for 500 runs. 38.8%
Correct guesses = 193 for 500 runs. 38.6%
Correct guesses = 202 for 500 runs. 40.4%
Correct guesses = 175 for 500 runs. 35.0%
Number of 500 runs = 10
Ave. Correct guesses 38.78% expected 38.9%
Chance of selecting A is 1/3
Chance of selecting B is 1/3
Chance of selecting C is 1/3
Chance of selecting A is 3/6, and so chance of both answer and guess 3/18
Chance of selecting B is 2/6 and so chance of both answer and guess 2/18
Chance of selecting C is 1/6 and so chance of both answer and guess 1/18
Therefore the chance of a random guess being correct for (A,B,C,A,B,A) is
6/18 or 33.3%
Random guess for ['A', 'B', 'C', 'B', 'A', 'A']
Correct guesses = 157 for 500 runs. 31.4 %
Correct guesses = 160 for 500 runs. 32.0 %
Correct guesses = 166 for 500 runs. 33.2 %
Correct guesses = 174 for 500 runs. 34.8 %
Correct guesses = 167 for 500 runs. 33.4 %
Correct guesses = 151 for 500 runs. 30.2 %
Correct guesses = 169 for 500 runs. 33.8 %
Correct guesses = 175 for 500 runs. 35.0 %
Correct guesses = 181 for 500 runs. 36.2 %
Correct guesses = 166 for 500 runs. 33.2 %
Number of 500 runs = 10
Ave. Correct guesses = 33.32 % expected 33.3 %
# Program to calculate chance of success of correctly choosing when randomly selecting from collection of items
import random
print() # add blank line
# alternative values commented out
# values = ['A', 'B', 'C', 'A', 'A']
# values = ['A', 'B', 'C', 'B', 'A', 'A']
values = ['A', 'B', 'C', 'A']
print(" Random guess for ", values)
print()
# Populate the list with values
# values = ['A', 'B', 'C', 'A','A']
correct_values = ['A', 'B', 'C']
# print (correct_values.count())
expected = 1/int(len(correct_values))
count = 0 # number of correct guesses in one run
total = 0
count_total = 0
runs = 10 # number of runs
tests = 500 # number of trials in the run
i1 = i2 = 0 # set while counters to zero
while i1 < runs:
i1 = i1 + 1
i2 = 0 # reset tests while counter
while i2 < tests:
i2 = i2 + 1
# Randomly choose correct value
random_choice_correct = random.choice(correct_values)
# Randomly guess correct value
random_choice_guess = random.choice(values)
total = total + 1
if random_choice_guess == random_choice_correct:
count = count + 1 # add number of correct guesses
print("Correct guesses = ", count, "for ", tests, " runs.", count * 100 / tests,"%"),
count_total = count_total + count # add correct answers for each run
count = total = 0
print()
print("Number of ", tests, " runs = ", runs)
print()
expected = round(expected*100, 1)
print("Ave. Correct guesses = ", count_total * 100 / (tests * runs),"% expected ", expected,"%")