It does sound like it could likely be an electrical problem. I had a mini cooper with a bad ground wire on the battery do the same thing. Also, I had a bad crank position sensor in my STI once and it would cut out, shudder, and sometimes just die the instant it hit 4k rpm. If the battery connections aren't the issue, I'd take it in for warranty repair. Good luck!