Add up all the frequencies to the get the total number of occurrences:
2 + 2 + 16 + 10 + 9 + 4 + x + 2 = x + 45
Then the probability corresponding to a given frequency is equal to (frequency)/(sum of frequencies). For example, the probability that a randomly chosen student has read 1 book in the marathon is 2/(x + 45); the probability of having read 4 books is 10/(x + 45); etc.
The mean is computed by multiplying each book count by their respective probability, and adding these all up. If the mean is 4.28, then
Simplifying the left side gives
Solve for x :