add code for confidence regions

Code is very rough, will be running more smoothly soon