Ankur Dave created SPARK-3578:
---------------------------------

             Summary: GraphGenerators.sampleLogNormal sometimes returns 
too-large result
                 Key: SPARK-3578
                 URL: https://issues.apache.org/jira/browse/SPARK-3578
             Project: Spark
          Issue Type: Bug
    Affects Versions: 1.2.0
            Reporter: Ankur Dave
            Assignee: Ankur Dave
            Priority: Minor


GraphGenerators.sampleLogNormal is supposed to return an integer strictly less 
than maxVal. However, it violates this guarantee. It generates its return value 
as follows:

{code}
var X: Double = maxVal

while (X >= maxVal) {
  val Z = rand.nextGaussian()
  X = math.exp(mu + sigma*Z)
}
math.round(X.toFloat)
{code}

When X is sampled to be close to (but less than) maxVal, then it will pass the 
while loop condition, but the rounded result will be equal to maxVal, which 
will fail the test.

For example, if maxVal is 5 and X is 4.9, then X < maxVal, but 
math.round(X.toFloat) is 5.

A solution is to truncate X instead of rounding it.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to