Class

eu.shiftforward.apso.Implicits

ApsoRandom

Related Doc: package Implicits

Permalink

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)

    Permalink

    rand

    the Random instance to which the new methods are provided.

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def choose[T](seq: IndexedSeq[T]): Option[T]

    Permalink

    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]

    Permalink

    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]

    Permalink

    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]

    Permalink
    Definition Classes
    AnyVal → Any
  9. def increasingUniformStream(n: Int): Stream[Double]

    Permalink

    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

    Permalink
    Definition Classes
    Any
  11. def monteCarlo[T](seq: Traversable[(T, Double)], r: Double = rand.nextDouble()): Option[T]

    Permalink

    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]

    Permalink

    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

    Permalink

    the Random instance to which the new methods are provided.

  14. def reservoirSample[T](seq: TraversableOnce[T]): Option[T]

    Permalink

    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]

    Permalink

    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]

    Permalink

    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

    Permalink
    Definition Classes
    Any

Inherited from AnyVal

Inherited from Any

Ungrouped