What you didn't state above is that you restored your device and set it up as new. Having said that, I recommend you do the following in order.
1. Go to Settings - General - Reset and then select "Reset All Settings". Afterwards, use your device like you normally would and see if it has random restarts. If not, assume the problem is fixed. If the random restarts began again, go to step 2.
2. Go to Settings - General -Reset and then select "Reset All Network Settings". Having a low wireless signal can cause reboots. If you are experiencing low wireless signals, contact your wireless carrier to see if they can troubleshoot from their end. If you have excellent wireless coverage/signal, go to step 3.
3. You stated that you "changed the battery". Did you replace it with a new battery or one from a broken iPhone 5? Are you certain you replaced it correctly as well as put the device back together correctly? If you're unsure, retrace your steps. If you are sure, go to step 4.
4. Put the device in DFU mode, connect it to your computer, and when iTunes detects that it is in recovery, select to restore and update. When the process is complete, do NOT restore from a backup. Set it up as new. This should be all that is needed to fix the problem, however, if the random reboots continue, go to step 5.
5. Make a genius bar appointment with the nearest Apple Store.