apache/spark — pull request #2439 by ankurdave (2014-09-17 23:20:21+00:00)
Title: [SPARK-3578] Fix upper bound in GraphGenerators.sampleLogNormal

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

```scala
var X: Double = maxVal

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

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.

Instead of rounding X to the nearest integer, this PR rounds X down using `math.floor(X).toInt`. This is necessary to enable negative bounds.