Github user mengxr commented on a diff in the pull request: https://github.com/apache/spark/pull/3680#discussion_r22062823 --- Diff: mllib/src/main/scala/org/apache/spark/mllib/random/RandomDataGenerator.scala --- @@ -99,3 +99,69 @@ class PoissonGenerator(val mean: Double) extends RandomDataGenerator[Double] { override def copy(): PoissonGenerator = new PoissonGenerator(mean) } + +/** + * :: DeveloperApi :: + * Generates i.i.d. samples from the exponential distribution with the given mean. + * + * @param mean mean for the exponential distribution. + */ +@DeveloperApi +class ExponentialGenerator(val mean: Double) extends RandomDataGenerator[Double] { + + private var rng = new ExponentialDistribution(mean) + + override def nextValue(): Double = rng.sample() + + override def setSeed(seed: Long) { + rng = new ExponentialDistribution(mean) + rng.reseedRandomGenerator(seed) + } + + override def copy(): ExponentialGenerator = new ExponentialGenerator(mean) +} + +/** + * :: DeveloperApi :: + * Generates i.i.d. samples from the gamma distribution with the given shape and scale. + * + * @param shape shape for the gamma distribution. + * @param scale scale for the gamma distribution + */ +@DeveloperApi +class GammaGenerator(val shape: Double, val scale: Double) extends RandomDataGenerator[Double] { + + private var rng = new GammaDistribution(shape, scale) + + override def nextValue(): Double = rng.sample() + + override def setSeed(seed: Long) { + rng = new GammaDistribution(shape, scale) --- End diff -- ditto
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org