[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 <578395184@qq.com> Signed-off-by: Sean Owen <srowen@gmail.com>
This commit is contained in:
parent
ad187227f1
commit
1cf18a2277
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue