To isolate software and hardware problems, I always use an external USB disk. Since bare bones OS X fits comfortably into a 32 Gb drive, get yourself an external USB drive, which could be a standard HDD in an enclosure, a USB flash disk or ideally a USB 3 SSD disk. Install Mavericks, Yosemite or El Capitan into this drive but do not sign into iCloud during or after the installation to keep it totally isolated.
Then, boot from this external disk and see if you still experience the same problem. This way your original drive with all your files and settings remains untouched until you correctly diagnose the problem.
When you boot from this virgin and "Gandhi" version of OS X and the problem is still there, then it is hardware related and you can take it to Apple to get it fixed. If the problem does not show, however, then your best bet is to re install OS X.