BiasedNumbers

Utility classes for selecting numbers at random, but not necessarily in an uniform way. The implementation will try to pick "evil" numbers more often than uniform selection would. This includes exact range boundaries, numbers very close to range boundaries, numbers very close (or equal) to zero, etc.

The exact method of selection is implementation-dependent and may change (if we find even more evil ways).

Functions

Link copied to clipboard
fun fuzzDown(r: Random, v: Double, min: Double): Double
fun fuzzDown(r: Random, v: Float, min: Float): Float

Fuzzify the input value by decreasing it by a few ulps, but never past min.

Link copied to clipboard
fun fuzzUp(r: Random, v: Double, max: Double): Double
fun fuzzUp(r: Random, v: Float, max: Float): Float

Fuzzify the input value by increasing it by a few ulps, but never past max.

Link copied to clipboard

A random double between min (inclusive) and max (inclusive). If you wish to have an exclusive range, use Math.nextAfter to adjust the range.

Link copied to clipboard

A random float between min (inclusive) and max (inclusive). If you wish to have an exclusive range, use Math.nextAfter to adjust the range.