Skip to content

Commit 0b09604

Browse files
rui-moPHILO-HE
authored andcommitted
Fix corr accuracy
1 parent 6dab43a commit 0b09604

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

velox/functions/prestosql/aggregates/CovarianceAggregates.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,8 @@ struct CorrResultAccessor {
236236
}
237237

238238
static double result(const CorrAccumulator& accumulator) {
239-
double stddevX = std::sqrt(accumulator.m2X());
240-
double stddevY = std::sqrt(accumulator.m2Y());
241-
return accumulator.c2() / stddevX / stddevY;
239+
// Modify the calculation order to maintain the same accuracy with spark.
240+
return accumulator.c2() / std::sqrt(accumulator.m2X() * accumulator.m2Y());
242241
}
243242
};
244243

0 commit comments

Comments
 (0)