Typically the mpg computers are very accurate, often within 5% and almost
always within 10%. That may seem like a lot of margin of error, but that
would be 1-2 mpg at 20 mpg.
The computer knows most of the variables with great accuracy: the distance
traveled (as displayed by your odometer), the engine speed, the amount of
time the ECU is commanding the fuel injectors to stay open. All it does not
know directly is the fuel pressure, which determines the actual amount of
fuel injected compared to the expected amount.
Mike