if (array1.length() != array2.length())
return ExprError.NA;
if (array1.length() == 0 || array2.length() == 0)
return ExprError.DIV0;
Expr ea1 = AVERAGE.average(array1);
if (ea1 instanceof ExprError)
return ea1;
double average1 = ((ExprNumber) ea1).doubleValue();
Expr ea2 = AVERAGE.average(array2);
if (ea2 instanceof ExprError)
return ea2;
double average2 = ((ExprNumber) ea2).doubleValue();
int count = 0;
double p = 0;
int len = array1.length();
for (int i = 0; i < len; i++) {
Expr x = array1.get(i);
Expr y = array2.get(i);
if (isNumber(x) && isNumber(y)) {
p += (asDouble(x, true) - average1) *
(asDouble(y, true) - average2);
count++;
}