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

    https://github.com/apache/spark/pull/7075#discussion_r35951096
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/stat/test/KolmogorovSmirnovTest.scala
 ---
    @@ -190,5 +191,93 @@ private[stat] object KolmogorovSmirnovTest extends 
Logging {
         val pval = 1 - new KolmogorovSmirnovTest().cdf(ksStat, n.toInt)
         new KolmogorovSmirnovTestResult(pval, ksStat, 
NullHypothesis.OneSampleTwoSided.toString)
       }
    +
    +  /**
    +   * Implements a two-sample, two-sided Kolmogorov-Smirnov test, which 
tests if the 2 samples
    +   * come from the same distribution
    +   * @param data1 `RDD[Double]` first sample of data
    +   * @param data2 `RDD[Double]` second sample of data
    +   * @return 
[[org.apache.spark.mllib.stat.test.KolmogorovSmirnovTestResult]] with the test
    +   *        statistic, p-value, and appropriate null hypothesis
    +   */
    +  def testTwoSamples(data1: RDD[Double], data2: RDD[Double]): 
KolmogorovSmirnovTestResult = {
    +    val n1 = data1.count().toDouble
    +    val n2 = data2.count().toDouble
    +    val isSample1 = true // identifier for sample 1, needed after co-sort
    +    // combine identified samples
    +    val joinedData = data1.map(x => (x, isSample1)) ++ data2.map(x => (x, 
!isSample1))
    +    // co-sort and operate on each partition
    +    val localData = joinedData.sortBy { case (v, id) => v }.mapPartitions 
{ part =>
    --- End diff --
    
    `.sortByKey`? I think the `mapPartitions` doesn't need braces, just parens, 
but that's tiny.


---
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