Could be many things. However, I have had good luck with reinstalling Windows. You can try a refresh first (leaving your programs and data alone), but may need a clean (complete) reinstall, Doing this a a rather painful process as you need to reinstall all you programs and data (from backup). What version of Windows are you using?
If you have already tried reinstalling Windows, the next stop would be to check the hardware. HP has a system diagnostic available. I would advise running that overnight and seeing what it says. Keep in mind that intermittent problems like this can be very difficult to narrow down. Some people will suggest "reseating" the RAM/ Drive/etc but there is a risk of damaging something else by opening your machine that is greater, I think, than trying this.
The HP diagnostic may already be installed on your machine (browse on the internet to find out how to start it). If not, you can download it from HP support. Set it up to loop continuously and let it run for hours. Good luck.