Packages

c

com.fulcrumgenomics.math

BinomialDistribution

class BinomialDistribution extends AnyRef

A high-precision implementation of the math for binomial probabilities. This implementation is several times slower (though not orders of magnitude slower) than the implementation in Apache Commons Math, but retains precision throughout the computation where the Commons implementation underflows.

One implementation choice to be aware of when using this implementation is that each instance of the class will calculate and cache factorials up to factorial(n) where n is the highest value of n supplied to any call to probability() or cumulativeProbability(). Thus to ensure reasonable performance it is recommended to create one instance of this class and reuse it for as many calculations as is practical.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BinomialDistribution
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new BinomialDistribution(mc: MathContext = MathContext.UNLIMITED)

    mc

    the MathContext to use for controlling precision and rounding. Changing from the default MathContext.UNLIMITED can lead to a loss of precision.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from BinomialDistribution to any2stringadd[BinomialDistribution] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (BinomialDistribution, B)
    Implicit
    This member is added by an implicit conversion from BinomialDistribution to ArrowAssoc[BinomialDistribution] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def coefficient(n: Int, k: Int): BigInt

    Computes the binomial coefficient, i.e.

    Computes the binomial coefficient, i.e. the number of combinations of k items given a total of n items, often phrased "n choose k".

    n

    The number of items being picked from

    k

    The number of items being picked (must be 0 <= k <= n)

    returns

    The number of combinations of k items from n

  9. def cumulativeProbability(k: Int, n: Int, p: BigDecimal, lower: Boolean = true): BigDecimal

    Calculates the cumulative probability of [0, k] successes from n trials with p probability of success in any individual trial.

    Calculates the cumulative probability of [0, k] successes from n trials with p probability of success in any individual trial. Akin to pbinom in R.

    k

    the number of successes to compute the cumulative probability up to, inclusive

    n

    the number of trials

    p

    the probability of success in any single trial

    lower

    if true return the cumulative probability of (0,k) trials inclusive otherwise return the cumulative probability of (k+1, n) trials inclusive.

  10. def ensuring(cond: (BinomialDistribution) ⇒ Boolean, msg: ⇒ Any): BinomialDistribution
    Implicit
    This member is added by an implicit conversion from BinomialDistribution to Ensuring[BinomialDistribution] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: (BinomialDistribution) ⇒ Boolean): BinomialDistribution
    Implicit
    This member is added by an implicit conversion from BinomialDistribution to Ensuring[BinomialDistribution] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: Boolean, msg: ⇒ Any): BinomialDistribution
    Implicit
    This member is added by an implicit conversion from BinomialDistribution to Ensuring[BinomialDistribution] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: Boolean): BinomialDistribution
    Implicit
    This member is added by an implicit conversion from BinomialDistribution to Ensuring[BinomialDistribution] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from BinomialDistribution to StringFormat[BinomialDistribution] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  18. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  19. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  20. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  21. val mc: MathContext
  22. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. final def notify(): Unit
    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  25. def probability(k: Int, n: Int, p: BigDecimal): BigDecimal

    Calculates the probability of exactly k successes in n trials given p probability.

    Calculates the probability of exactly k successes in n trials given p probability. Akin to dbinom in R.

    k

    The number of successful trials

    n

    The number of trials

    p

    The probability of the success in any one trial

    returns

    The probability of exactly k successes in n trials of p probability

  26. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  27. def toString(): String
    Definition Classes
    AnyRef → Any
  28. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. def [B](y: B): (BinomialDistribution, B)
    Implicit
    This member is added by an implicit conversion from BinomialDistribution to ArrowAssoc[BinomialDistribution] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from BinomialDistribution to any2stringadd[BinomialDistribution]

Inherited by implicit conversion StringFormat from BinomialDistribution to StringFormat[BinomialDistribution]

Inherited by implicit conversion Ensuring from BinomialDistribution to Ensuring[BinomialDistribution]

Inherited by implicit conversion ArrowAssoc from BinomialDistribution to ArrowAssoc[BinomialDistribution]

Ungrouped