You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Ankur Dave (JIRA)" <ji...@apache.org> on 2014/09/18 01:14:33 UTC

[jira] [Updated] (SPARK-3578) GraphGenerators.sampleLogNormal sometimes returns too-large result

     [ https://issues.apache.org/jira/browse/SPARK-3578?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ankur Dave updated SPARK-3578:
------------------------------
    Description: 
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 round X down instead of to the nearest integer.

  was:
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.


> 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 round X down instead of to the nearest integer.



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

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