# Binomial

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

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

n

is the number of coin flips

p

the probability of any one being true

Linear Supertypes
Serializable, Serializable, Product, Equals, Moments[Double, Double], DiscreteDistr[Int], Rand[Int], Density[Int], AnyRef, Any
Ordering
1. Alphabetic
2. By inheritance
Inherited
1. Binomial
2. Serializable
3. Serializable
4. Product
5. Equals
6. Moments
7. DiscreteDistr
8. Rand
9. Density
10. AnyRef
11. Any
1. Hide All
2. Show all
Learn more about member selection
Visibility
1. Public
2. All

### Instance Constructors

1. #### new Binomial(n: Int, p: Double)(implicit rand: RandBasis = Rand)

n

is the number of coin flips

p

the probability of any one being true

### Value Members

1. #### final def !=(arg0: AnyRef): Boolean

Definition Classes
AnyRef
2. #### final def !=(arg0: Any): Boolean

Definition Classes
Any
3. #### final def ##(): Int

Definition Classes
AnyRef → Any
4. #### final def ==(arg0: AnyRef): Boolean

Definition Classes
AnyRef
5. #### final def ==(arg0: Any): Boolean

Definition Classes
Any
6. #### def apply(x: Int): Double

Returns the unnormalized value of the measure

Returns the unnormalized value of the measure

Definition Classes
DiscreteDistrDensity
7. #### final def asInstanceOf[T0]: T0

Definition Classes
Any
8. #### def clone(): AnyRef

Attributes
protected[java.lang]
Definition Classes
AnyRef
Annotations
@throws( ... )
9. #### def condition(p: (Int) ⇒ Boolean): Rand[Int]

Definition Classes
Rand
10. #### def draw(): Int

Gets one sample from the distribution.

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

Definition Classes
BinomialRand
11. #### def drawOpt(): Option[Int]

Overridden by filter/map/flatmap for monadic invocations.

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

Definition Classes
Rand
12. #### def entropy: Double

with an additive O(1/n) term

with an additive O(1/n) term

Definition Classes
BinomialMoments
13. #### final def eq(arg0: AnyRef): Boolean

Definition Classes
AnyRef
14. #### def filter(p: (Int) ⇒ Boolean): Rand[Int]

Definition Classes
Rand
15. #### def finalize(): Unit

Attributes
protected[java.lang]
Definition Classes
AnyRef
Annotations
@throws( classOf[java.lang.Throwable] )
16. #### def flatMap[E](f: (Int) ⇒ Rand[E]): Rand[E]

Converts a random sampler of one type to a random sampler of another type.

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

f

the transform to apply to the sampled value.

Definition Classes
Rand
17. #### def foreach(f: (Int) ⇒ Unit): Unit

Samples one element and qpplies the provided function to it.

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) }
```

f

the function to be applied

Definition Classes
Rand
18. #### def get(): Int

Definition Classes
Rand
19. #### final def getClass(): Class[_]

Definition Classes
AnyRef → Any
20. #### final def isInstanceOf[T0]: Boolean

Definition Classes
Any
21. #### def logApply(x: Int): Double

Returns the log unnormalized value of the measure

Returns the log unnormalized value of the measure

Definition Classes
DiscreteDistrDensity
22. #### def logProbabilityOf(k: Int): Double

Definition Classes
BinomialDiscreteDistr
23. #### def map[E](f: (Int) ⇒ E): Rand[E]

Converts a random sampler of one type to a random sampler of another type.

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 2*x

f

the transform to apply to the sampled value.

Definition Classes
Rand
24. #### def mean: Double

Definition Classes
BinomialMoments
25. #### def mode: Double

Definition Classes
BinomialMoments
26. #### val n: Int

is the number of coin flips

27. #### final def ne(arg0: AnyRef): Boolean

Definition Classes
AnyRef
28. #### final def notify(): Unit

Definition Classes
AnyRef
29. #### final def notifyAll(): Unit

Definition Classes
AnyRef
30. #### val p: Double

the probability of any one being true

31. #### def probabilityOf(k: Int): Double

Returns the probability of that draw.

Returns the probability of that draw.

Definition Classes
BinomialDiscreteDistr
32. #### def sample(n: Int): IndexedSeq[Int]

Gets n samples from the distribution.

Gets n samples from the distribution.

Definition Classes
Rand
33. #### def sample(): Int

Gets one sample from the distribution.

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

Definition Classes
Rand
34. #### 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

Definition Classes
Rand
35. #### final def synchronized[T0](arg0: ⇒ T0): T0

Definition Classes
AnyRef
36. #### def toString(): String

Definition Classes
Binomial → AnyRef → Any
37. #### def unnormalizedLogProbabilityOf(x: Int): Double

Definition Classes
DiscreteDistr
38. #### 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

Definition Classes
DiscreteDistr
39. #### def variance: Double

Definition Classes
BinomialMoments
40. #### final def wait(): Unit

Definition Classes
AnyRef
Annotations
@throws( ... )
41. #### final def wait(arg0: Long, arg1: Int): Unit

Definition Classes
AnyRef
Annotations
@throws( ... )
42. #### final def wait(arg0: Long): Unit

Definition Classes
AnyRef
Annotations
@throws( ... )
43. #### def withFilter(p: (Int) ⇒ Boolean): Rand[Int]

Definition Classes
Rand