spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srowen <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-14163][CORE] SumEvaluator and countAppr...
Date Tue, 29 Mar 2016 13:38:30 GMT
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12016#discussion_r57723732
  
    --- Diff: core/src/main/scala/org/apache/spark/partial/SumEvaluator.scala ---
    @@ -40,30 +41,39 @@ private[spark] class SumEvaluator(totalOutputs: Int, confidence: Double)
       override def currentResult(): BoundedDouble = {
         if (outputsMerged == totalOutputs) {
           new BoundedDouble(counter.sum, 1.0, counter.sum, counter.sum)
    -    } else if (outputsMerged == 0) {
    +    } else if (outputsMerged == 0 || counter.count == 0) {
           new BoundedDouble(0, 0.0, Double.NegativeInfinity, Double.PositiveInfinity)
         } else {
           val p = outputsMerged.toDouble / totalOutputs
           val meanEstimate = counter.mean
    -      val meanVar = counter.sampleVariance / counter.count
           val countEstimate = (counter.count + 1 - p) / p
    -      val countVar = (counter.count + 1) * (1 - p) / (p * p)
           val sumEstimate = meanEstimate * countEstimate
    -      val sumVar = (meanEstimate * meanEstimate * countVar) +
    -                   (countEstimate * countEstimate * meanVar) +
    -                   (meanVar * countVar)
    -      val sumStdev = math.sqrt(sumVar)
    -      val confFactor = {
    -        if (counter.count > 100) {
    +
    +      val meanVar = counter.sampleVariance / counter.count
    +
    +      // branch at this point because counter.count == 1 implies counter.sampleVariance
== Nan
    +      // and we don't want to ever return a bound of NaN
    +      if (meanVar == Double.NaN || counter.count == 1) {
    --- End diff --
    
    `NaN != NaN`; you'd have to use `Double.isNaN`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message