Binomial

case class Binomial(n: Int, p: Double)(implicit rand: RandBasis) extends DiscreteDistr[Int] with Moments[Double, Double]

A binomial distribution returns how many coin flips out of n are heads, where numYes is the probability of any one coin being heads.

Value Params
n

is the number of coin flips

p

the probability of any one being true

trait Product
trait Equals
trait Moments[Double, Double]
trait DiscreteDistr[Int]
trait Rand[Int]
trait Serializable
trait Density[Int]
class Object
trait Matchable
class Any

Type members

Types

type Distr = Gamma

Value members

Concrete methods

override def draw(): Int
Definition Classes
def entropy: Double

with an additive O(1/n) term

with an additive O(1/n) term

override def logProbabilityOf(k: Int): Double
Definition Classes
def mean: Double
def mode: Double
def probabilityOf(k: Int): Double
override def toString(): String
Definition Classes
Any
def variance: Double

Inherited methods

def apply(x: Int): Double
Inherited from
DiscreteDistr
def condition(p: Int => Boolean): Rand[Int]
Inherited from
Rand
def drawOpt(): Option[Int]

Overridden by filter/map/flatmap for monadic invocations. Basically, rejeciton samplers will return None here

Overridden by filter/map/flatmap for monadic invocations. Basically, rejeciton samplers will return None here

Inherited from
Rand
def filter(p: Int => Boolean): Rand[Int]
Inherited from
Rand
def flatMap[E](f: Int => Rand[E]): Rand[E]

Converts a random sampler of one type to a random sampler of another type. Examples: randInt(10).flatMap(x => randInt(3 * x.asInstanceOf[Int]) gives a Rand[Int] in the range [0,30] Equivalently, for(x <- randInt(10); y <- randInt(30 *x)) yield y

Converts a random sampler of one type to a random sampler of another type. Examples: randInt(10).flatMap(x => randInt(3 * x.asInstanceOf[Int]) gives a Rand[Int] in the range [0,30] Equivalently, for(x <- randInt(10); y <- randInt(30 *x)) yield y

Value Params
f

the transform to apply to the sampled value.

Inherited from
Rand
def foreach(f: Int => Unit): Unit

Samples one element and qpplies the provided function to it. Despite the name, the function is applied once. Sample usage:

Samples one element and qpplies the provided function to it. Despite the name, the function is applied once. Sample usage:

<pre> for(x &lt;- Rand.uniform) { println(x) } </pre>

Value Params
f

the function to be applied

Inherited from
Rand
def get(): Int
Inherited from
Rand
override def logApply(x: Int): Double
Definition Classes
Inherited from
DiscreteDistr
def map[E](f: Int => E): Rand[E]

Converts a random sampler of one type to a random sampler of another type. Examples: uniform.map(_2) gives a Rand[Double] in the range [0,2] Equivalently, for(x <- uniform) yield 2x

Converts a random sampler of one type to a random sampler of another type. Examples: uniform.map(_2) gives a Rand[Double] in the range [0,2] Equivalently, for(x <- uniform) yield 2x

Value Params
f

the transform to apply to the sampled value.

Inherited from
Rand
def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product
def sample(n: Int): IndexedSeq[Int]

Gets n samples from the distribution.

Gets n samples from the distribution.

Inherited from
Rand
def sample(): Int

Gets one sample from the distribution. Equivalent to get()

Gets one sample from the distribution. Equivalent to get()

Inherited from
Rand
def samples: Iterator[Int]

An infinitely long iterator that samples repeatedly from the Rand

An infinitely long iterator that samples repeatedly from the Rand

Returns

an iterator that repeatedly samples

Inherited from
Rand
def samplesVector[U >: Int](size: Int)(implicit m: ClassTag[U]): DenseVector[U]

Return a vector of samples.

Return a vector of samples.

Inherited from
Rand
def unnormalizedLogProbabilityOf(x: Int): Double
Inherited from
DiscreteDistr
def unnormalizedProbabilityOf(x: Int): Double

Returns the probability of that draw up to a constant

Returns the probability of that draw up to a constant

Inherited from
DiscreteDistr
def withFilter(p: Int => Boolean): Rand[Int]
Inherited from
Rand