Random turning off is usually an indication of power management or energy saver issues such as:
1. Corruption in Energy Saver, power management cache and/or preferences.
2. Corruption in the directory which leads to inability of the machine to see number 1 all the time.
3. Hard disk issues which can lead to 1 and 2.
4. Power cord fraying.
5. Internal or power brick power supply failing.
6. Electricity issues with the outlet used. An APC battery backup surge protector with an a current battery installed would help.
7. Battery failing because of heat or warranty related issue.
My suggestion is if you are having random shut offs, is to back up your data at least twice.
Run the hardware test that came with your machine's restore disks.
If anything is detected, or you suspect warping of your battery, or you've made sure neither of these articles applies to your machine overheating:
Then take it to an authorized Apple service center to have it looked at. Especially do this, if it is apparently happening right after an erase and install and no third party peripherals are connected. This would be an indication that at least 1 and 2's causes are not to blame, since an erased system in theory has no data corruption, and no third party applications to interfere with the system's operation.