Skip to content

Commit

Permalink
Fix corr accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo authored and PHILO-HE committed Oct 29, 2023
1 parent 6dab43a commit 0b09604
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions velox/functions/prestosql/aggregates/CovarianceAggregates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,8 @@ struct CorrResultAccessor {
}

static double result(const CorrAccumulator& accumulator) {
double stddevX = std::sqrt(accumulator.m2X());
double stddevY = std::sqrt(accumulator.m2Y());
return accumulator.c2() / stddevX / stddevY;
// Modify the calculation order to maintain the same accuracy with spark.
return accumulator.c2() / std::sqrt(accumulator.m2X() * accumulator.m2Y());
}
};

Expand Down

0 comments on commit 0b09604

Please sign in to comment.