Multinomial

case class Multinomial[T, I](params: T)(implicit ev: ConversionOrSubtype[T, QuasiTensor[I, Double]], sumImpl: Impl[T, Double], rand: RandBasis) extends DiscreteDistr[I]

Represents a Multinomial distribution over elements. You can make a distribution over any breeze.linalg.QuasiTensor, which includes DenseVectors and Counters.

TODO: I should probably rename this to Discrete or something, since it only handles one draw.

Companion:
object
trait Product
trait Equals
trait DiscreteDistr[I]
trait Rand[I]
trait Serializable
trait Density[I]
class Object
trait Matchable
class Any

Value members

Concrete methods

def draw(): I
def drawNaive(): I
def expectedValue[U](f: I => U)(implicit vs: VectorSpace[U, Double]): U
override def toString: String
Definition Classes
Any
override def unnormalizedProbabilityOf(e: I): Double
Definition Classes

Inherited methods

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

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: I => Boolean): Rand[I]
Inherited from:
Rand
def flatMap[E](f: I => 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 parameters:
f

the transform to apply to the sampled value.

Inherited from:
Rand
def foreach(f: I => 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:

 for(x <- Rand.uniform) { println(x) } 
Value parameters:
f

the function to be applied

Inherited from:
Rand
def get(): I
Inherited from:
Rand
override def logApply(x: I): Double
Definition Classes
Inherited from:
DiscreteDistr
Inherited from:
DiscreteDistr
def map[E](f: I => 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 parameters:
f

the transform to apply to the sampled value.

Inherited from:
Rand
Inherited from:
Product
def sample(n: Int): IndexedSeq[I]

Gets n samples from the distribution.

Gets n samples from the distribution.

Inherited from:
Rand
def sample(): I

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

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

Inherited from:
Rand

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 >: I](size: Int)(implicit m: ClassTag[U]): DenseVector[U]

Return a vector of samples.

Return a vector of samples.

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

Concrete fields

val sum: Double