Packages

implicit final class ApsoRandom extends AnyVal

Implicit class that provides new methods for random number generators.

Linear Supertypes
AnyVal, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ApsoRandom
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ApsoRandom(rand: Random)

    rand

    the Random instance to which the new methods are provided.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def choose[T](seq: IndexedSeq[T]): Option[T]

    Chooses a random element from an indexed sequence.

    Chooses a random element from an indexed sequence.

    T

    the type of the elements

    seq

    the indexed sequence of elements to choose from

    returns

    the selected element wrapped in a Some if seq has at least one element, None otherwise.

  6. def chooseN[T](seq: Seq[T], n: Int): Seq[T]

    Chooses n random element from a sequence.

    Chooses n random element from a sequence.

    T

    the type of the elements

    seq

    the sequence of elements to choose from

    returns

    the selected elements

  7. def decreasingUniformStream(n: Int): Stream[Double]

    Returns a decreasingly ordered stream of n doubles in [0, 1], according to a uniform distribution.

    Returns a decreasingly ordered stream of n doubles in [0, 1], according to a uniform distribution. More Info: BENTLEY, SAXE, Generating Sorted Lists of Random Numbers

    n

    amount of numbers to generate

    returns

    ordered stream of doubles

  8. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  9. def increasingUniformStream(n: Int): Stream[Double]

    Returns an increasingly ordered stream of n doubles in [0, 1], according to a uniform distribution.

    Returns an increasingly ordered stream of n doubles in [0, 1], according to a uniform distribution. More Info: BENTLEY, SAXE, Generating Sorted Lists of Random Numbers

    n

    amount of numbers to generate

    returns

    ordered stream of doubles

  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. def monteCarlo[T](seq: Traversable[(T, Double)], r: Double = rand.nextDouble()): Option[T]

    Chooses an element of a sequence according to a weight function.

    Chooses an element of a sequence according to a weight function.

    T

    the type of the elements in the sequence

    seq

    the pairs (element, probability) to choose from

    returns

    the selected element wrapped in a Some if some element was chosen, None otherwise. Not choosing any element can happen if the weights of the elements do not sum up to the maximum value of r.

    Annotations
    @inline()
  12. def monteCarlo[T](seq: Traversable[T], valueFunc: (T) ⇒ Double, r: Double): Option[T]

    Chooses an element of a sequence according to a weight function.

    Chooses an element of a sequence according to a weight function.

    T

    the type of the elements

    seq

    the elements to choose from

    valueFunc

    the function that maps elements to weights

    r

    the random value used to select the elements. If the default random value is used, the weighted selection uses 1.0 as the sum of all weights. To use another scale of weights, a random value between 0.0 and the maximum weight should be passed.

    returns

    the selected element wrapped in a Some if some element was chosen, None otherwise. Not choosing any element can happen if the weights of the elements do not sum up to the maximum value of r.

  13. val rand: Random
  14. def reservoirSample[T](seq: TraversableOnce[T]): Option[T]

    Chooses a random element of a traversable using the reservoir sampling technique, traversing only once the given sequence.

    Chooses a random element of a traversable using the reservoir sampling technique, traversing only once the given sequence.

    T

    the type of the elements

    seq

    the elements to choose from

    returns

    the selected element wrapped in a Some, or None if the traversable is empty.

  15. def samples[T](seq: Traversable[(T, Double)]): Iterator[T]

    Returns an infinite stream of weighted samples of a sequence.

    Returns an infinite stream of weighted samples of a sequence.

    T

    the type of the elements

    seq

    the pairs (element, probability) to choose from

    returns

    an infinite stream of weighted samples of a sequence.

    Annotations
    @inline()
  16. def samples[T](seq: Traversable[T], valueFunc: (T) ⇒ Double): Iterator[T]

    Returns an infinite stream of weighted samples of a sequence.

    Returns an infinite stream of weighted samples of a sequence.

    T

    the type of the elements

    seq

    the elements to choose from

    returns

    an infinite stream of weighted samples of a sequence.

  17. def toString(): String
    Definition Classes
    Any

Inherited from AnyVal

Inherited from Any

Ungrouped