本文整理汇总了Scala中org.apache.commons.math3.distribution.BinomialDistribution类的典型用法代码示例。如果您正苦于以下问题:Scala BinomialDistribution类的具体用法?Scala BinomialDistribution怎么用?Scala BinomialDistribution使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BinomialDistribution类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: Distributions
//设置package包名称以及导入依赖的类
package de.twiechert.benchmarks.linearroad.datagen.flink
import org.apache.commons.math3.distribution.{ZipfDistribution, BinomialDistribution, UniformIntegerDistribution}
object Distributions {
trait DiscreteDistribution {
def sample(cumulativeProbability: Double) : Int
}
case class DiscreteUniform(k: Int) extends DiscreteDistribution {
val distribution = new UniformIntegerDistribution(0, k - 1)
def sample(cp: Double) = distribution.inverseCumulativeProbability(cp)
}
case class Binomial(sampleSize: Int, successProbability: Double) extends DiscreteDistribution {
val distribution = new BinomialDistribution(sampleSize - 1, successProbability)
def sample(cp: Double) = distribution.inverseCumulativeProbability(cp) - 1
}
case class Zipf(sampleSize: Int, exponent: Double) extends DiscreteDistribution {
val distribution = new ZipfDistribution(sampleSize, exponent)
def sample(cp: Double) = distribution.inverseCumulativeProbability(cp) - 1
}
}
示例2: Distributions
//设置package包名称以及导入依赖的类
package de.tu_berlin.dima.bdapro.datagen.flink
import org.apache.commons.math3.distribution.{ZipfDistribution, BinomialDistribution, UniformIntegerDistribution}
object Distributions {
trait DiscreteDistribution {
def sample(cumulativeProbability: Double) : Int
}
case class DiscreteUniform(k: Int) extends DiscreteDistribution {
val distribution = new UniformIntegerDistribution(0, k - 1)
def sample(cp: Double) = distribution.inverseCumulativeProbability(cp)
}
case class Binomial(sampleSize: Int, successProbability: Double) extends DiscreteDistribution {
val distribution = new BinomialDistribution(sampleSize - 1, successProbability)
def sample(cp: Double) = distribution.inverseCumulativeProbability(cp) - 1
}
case class Zipf(sampleSize: Int, exponent: Double) extends DiscreteDistribution {
val distribution = new ZipfDistribution(sampleSize, exponent)
def sample(cp: Double) = distribution.inverseCumulativeProbability(cp) - 1
}
}