本文整理汇总了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
}
}
开发者ID:twiechert,项目名称:kafka-linearroad-peelbundle,代码行数:26,代码来源:Distributions.scala
示例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
}
}
开发者ID:cristiprg,项目名称:BDAPRO.GlobalStateML,代码行数:26,代码来源:Distributions.scala
注:本文中的org.apache.commons.math3.distribution.BinomialDistribution类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论