+ double varA = 4 / Atotal * (sumPcubed - a * a);
+ double varB = 4 / Btotal * (sumQcubed - b * b);
+ double varD = sumPQsq / Atotal + sumPsqQ / Btotal - d * d * (1/Atotal + 1/Btotal);
+ double covAD = 2 / Atotal * (sumPsqQ - a * d);
+ double covBD = 2 / Btotal * (sumPQsq - b* d);
+
+ double varT = d * d * (varA + varB) / pow(a + b - d, (double)4.0) + pow(a+b, (double)2.0) * varD / pow(a+b-d, (double)4.0)
+ - 2.0 * (a + b) * d / pow(a + b - d, (double)4.0) * (covAD + covBD);
+
+ double ci = 1.95 * sqrt(varT);
+