RandomDouble

Random generator for double values.

Description

The RandomDouble class allows you to generate random double values.

Static methods

nextDouble

Generates a random double value in the range [‘minYear’, ‘maxYear’].

public static nextDouble(min: number, max: number = null): number

  • min: number - (optional) minimum range value
  • max: number - max range value
  • returns: number - random double value.

updateDouble

Updates (drifts) a double value within specified range.

public static updateDouble(value: number, range: number = null): number

  • value: number - double value to drift.
  • range: number - (optional) range. Default: 10% of the value.
  • returns: number - updated double value.

Examples

let value1 = RandomDouble.nextDouble(5, 10);     // Possible result: 7.3
let value2 = RandomDouble.nextDouble(10);        // Possible result: 3.7
let value3 = RandomDouble.updateDouble(10, 3);   // Possible result: 9.2