fixing more array issues, got confidence ints very close to matlab code