Github user srowen commented on the issue:
https://github.com/apache/spark/pull/15687
In theory, it doesn't matter because the circumference has 0 width, but in
practice it could matter a very very small bit because of floating-point
round-off. It doesn't really matter for purposes of the example but I agree
it'd be nice to do the slightly more accurate thing, on principle. I made an
even simpler test to isolate away other effects:
```
var lt = 0
var lte = 0
val n = 1000000000
val random = new scala.util.Random()
for (i <- 0 until n) {
val x = 2.0 * random.nextDouble() - 1.0
val y = 2.0 * random.nextDouble() - 1.0
val dist = x * x + y * y
if (dist < 1.0) { lt += 1 }
if (dist <= 1.0) { lte += 1 }
}
val ltEstimate = 4.0 * lt / n
val lteEstimate = 4.0 * lte / n
println(ltEstimate - scala.math.Pi)
println(lteEstimate - scala.math.Pi)
```
I get exactly the same error of 2.910410207057623E-6 in both cases after 1
billion iterations. Therefore I'd suspect any difference is due to chance, but
I'm not sure what kind of results you got or whether they're highly unlikely to
be due to chance.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]