I bought a new iPhone 4S not more than 30days ago.. my iPhone 4S on iOS 5.1 was, what seemed to be, randomly powering off.. also, at times, I would pick up my iPhone and I can see the white busy circle going and then the phone would restart itself.. I say seems like it powers off because when I would pick up my iPhone, the screen is blank or black and neither the home button or sleep button would function to wake the iPhone.. each time this happened, I would have to do a hard reset to get the iPhone back on (pressing the home+power button together until the Apple logo appears).. this happened about 2-3 times a day, at random, with some days it not happening. I took the step of updating to the latest iOS, 5.1.1, to resolve this issue, but it still remained..
After reading through the Apple communities, I discovered that many other people have or are suffering with this issue, so i believed my iPhone to be defective..
Today I went to the the best Apple store known to me.. even with an appointment, I had to wait 60+minutes.. In the end, it was WELL WORTH the wait.. she took my phone to run a diagnostic test, she returned and happily replaced my phone with another.
If an restore/update doesn't work for you, go into the Apple store and ask them to replace it ;-)
..
.
Good Luck!!