You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sr...@apache.org on 2021/06/23 23:21:03 UTC
[spark] branch master updated: [SPARK-35851][GRAPHX] Modify the
wrong variable used in GraphGenerators.sampleLogNormal
This is an automated email from the ASF dual-hosted git repository.
srowen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 1cf18a2 [SPARK-35851][GRAPHX] Modify the wrong variable used in GraphGenerators.sampleLogNormal
1cf18a2 is described below
commit 1cf18a22775fecfae70f97ac345008dc70a8ba5f
Author: zengruios <57...@qq.com>
AuthorDate: Wed Jun 23 18:20:33 2021 -0500
[SPARK-35851][GRAPHX] Modify the wrong variable used in GraphGenerators.sampleLogNormal
### What changes were proposed in this pull request?
modify the wrong variable used in GraphGenerators.sampleLogNormal
### Why are the changes needed?
wrong variable used
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
UT
Closes #33010 from zengruios/SPARK-35851.
Authored-by: zengruios <57...@qq.com>
Signed-off-by: Sean Owen <sr...@gmail.com>
---
.../org/apache/spark/graphx/util/GraphGenerators.scala | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/graphx/src/main/scala/org/apache/spark/graphx/util/GraphGenerators.scala b/graphx/src/main/scala/org/apache/spark/graphx/util/GraphGenerators.scala
index 4197311..ea531b6 100644
--- a/graphx/src/main/scala/org/apache/spark/graphx/util/GraphGenerators.scala
+++ b/graphx/src/main/scala/org/apache/spark/graphx/util/GraphGenerators.scala
@@ -87,11 +87,10 @@ object GraphGenerators extends Logging {
}
/**
- * Randomly samples from a log normal distribution whose corresponding normal distribution has
- * the given mean and standard deviation. It uses the formula `X = exp(m+s*Z)` where `m`,
- * `s` are the mean, standard deviation of the lognormal distribution and
- * `Z ~ N(0, 1)`. In this function,
- * `m = e^(mu+sigma^2/2)` and `s = sqrt[(e^(sigma^2) - 1)(e^(2*mu+sigma^2))]`.
+ * Randomly samples from the given mean and standard deviation of the normal distribution.
+ * It uses the formula `X = exp(mu+sigma*Z)` where `mu`,
+ * `sigma` are the mean, standard deviation of the normal distribution and
+ * `Z ~ N(0, 1)`.
*
* @param mu the mean of the normal distribution
* @param sigma the standard deviation of the normal distribution
@@ -102,10 +101,6 @@ object GraphGenerators extends Logging {
mu: Double, sigma: Double, maxVal: Int, seed: Long = -1): Int = {
val rand = if (seed == -1) new Random() else new Random(seed)
- val sigmaSq = sigma * sigma
- val m = math.exp(mu + sigmaSq / 2.0)
- // expm1 is exp(m)-1 with better accuracy for tiny m
- val s = math.sqrt(math.expm1(sigmaSq) * math.exp(2*mu + sigmaSq))
// Z ~ N(0, 1)
var X: Double = maxVal
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org