Apoc.math.regr calculations

Hello Neo4j knowledgable community,

I have a question regarding one of the apoc math functions, namely apoc.math.regr I have been using it to compute the linear regression estimators (slope, intercept) and the goodness-of-fit measure (R-squared). However, I noticed there is a huge difference between what is resultant out of this function and what is computed manually and using other tools adopting the least square approach. Therefore, I would appreciate your advice in figuring out/understanding what is used in the computation using the apoc regr function