When the fuel pump died in my car, it was random like that. it would die, then could be brought back to life with a thump on the fuel tank. Since being replaced, all has been well. It sounds like it may be the same for your car, perhaps. The fuel pump is hard to test when it gets sporadic like that, but luckily it is not horribly difficult or expensive to replace.
Geoff