Github user brkyvz commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5858#discussion_r29549773
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/stat/StatFunctions.scala 
---
    @@ -23,29 +23,43 @@ import org.apache.spark.sql.types.{DoubleType, 
NumericType}
     
     private[sql] object StatFunctions {
       
    +  /** Calculate the Pearson Correlation Coefficient for the given columns 
*/
    +  private[sql] def pearsonCorrelation(df: DataFrame, cols: Seq[String]): 
Double = {
    +    val counts = collectStatisticalData(df, cols)
    +    counts.Ck / math.sqrt(counts.MkX * counts.MkY)
    --- End diff --
    
    It is, isn't it? The n - 1's cancel. I tested with sciPy Pearsonr method.
    That's why I have the non trivial (i, sqrt(i)) test.
    On May 2, 2015 10:32 AM, "Xiangrui Meng" <notificati...@github.com> wrote:
    
    > In
    > 
sql/core/src/main/scala/org/apache/spark/sql/execution/stat/StatFunctions.scala
    > <https://github.com/apache/spark/pull/5858#discussion_r29549089>:
    >
    > > @@ -23,29 +23,43 @@ import org.apache.spark.sql.types.{DoubleType, 
NumericType}
    > >
    > >  private[sql] object StatFunctions {
    > >
    > > +  /** Calculate the Pearson Correlation Coefficient for the given 
columns */
    > > +  private[sql] def pearsonCorrelation(df: DataFrame, cols: 
Seq[String]): Double = {
    > > +    val counts = collectStatisticalData(df, cols)
    > > +    counts.Ck / math.sqrt(counts.MkX * counts.MkY)
    >
    > Should be the sample correlation as well. In the unit tests, please
    > provide R commands that compute the correlation and the result, and verify
    > that we output the same value.
    >
    > —
    > Reply to this email directly or view it on GitHub
    > <https://github.com/apache/spark/pull/5858/files#r29549089>.
    >



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to