Skip to content

Commit

Permalink
modify the calculation order
Browse files Browse the repository at this point in the history
  • Loading branch information
liujiayi771 committed Mar 29, 2023
1 parent a1a631b commit 4f319c6
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 @@ -229,9 +229,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;
// Need to modify the calculation order to maintain the same accuracy as spark
return accumulator.c2() / std::sqrt(accumulator.m2X() * accumulator.m2Y());
}
};

Expand Down

0 comments on commit 4f319c6

Please sign in to comment.