time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

repl.txt (4099B)


      1 
      2 {{alias}}()
      3     Returns a pseudorandom integer on the interval `[1, 2147483646]`.
      4 
      5     This pseudorandom number generator (PRNG) is a linear congruential
      6     pseudorandom number generator (LCG) whose output is shuffled using the Bays-
      7     Durham algorithm. The shuffle step considerably strengthens the "randomness
      8     quality" of a simple LCG's output.
      9 
     10     The generator has a period of approximately `2.1e9`.
     11 
     12     An LCG is fast and uses little memory. On the other hand, because the
     13     generator is a simple LCG, the generator has recognized shortcomings. By
     14     today's PRNG standards, the generator's period is relatively short. In
     15     general, this generator is unsuitable for Monte Carlo simulations and
     16     cryptographic applications.
     17 
     18     Returns
     19     -------
     20     r: integer
     21         Pseudorandom number.
     22 
     23     Examples
     24     --------
     25     > var r = {{alias}}();
     26 
     27 
     28 {{alias}}.normalized()
     29     Returns a pseudorandom number on the interval `[0,1)`.
     30 
     31     Returns
     32     -------
     33     r: number
     34         Pseudorandom number.
     35 
     36     Examples
     37     --------
     38     > var r = {{alias}}.normalized();
     39 
     40 
     41 {{alias}}.factory( [options] )
     42     Returns a linear congruential pseudorandom number generator (LCG) whose
     43     output is shuffled.
     44 
     45     Parameters
     46     ----------
     47     options: Object (optional)
     48         Options.
     49 
     50     options.seed: integer|ArrayLikeObject<integer> (optional)
     51         Pseudorandom number generator seed. The seed may be either a positive
     52         signed 32-bit integer on the interval `[1, 2147483646]` or, for
     53         arbitrary length seeds, an array-like object containing signed 32-bit
     54         integers.
     55 
     56     options.state: Int32Array (optional)
     57         Pseudorandom number generator state. If provided, the `seed` option is
     58         ignored.
     59 
     60     options.copy: boolean (optional)
     61         Boolean indicating whether to copy a provided pseudorandom number
     62         generator state. Setting this option to `false` allows sharing state
     63         between two or more pseudorandom number generators. Setting this option
     64         to `true` ensures that a returned generator has exclusive control over
     65         its internal state. Default: true.
     66 
     67     Returns
     68     -------
     69     rand: Function
     70         Pseudorandom number generator (PRNG).
     71 
     72     Examples
     73     --------
     74     // Basic usage:
     75     > var rand = {{alias}}.factory();
     76     > r = rand();
     77     > r = rand();
     78 
     79     // Provide a seed:
     80     > rand = {{alias}}.factory( { 'seed': 1234 } );
     81     > r = rand()
     82     1421600654
     83 
     84 
     85 {{alias}}.NAME
     86     Generator name.
     87 
     88     Examples
     89     --------
     90     > var str = {{alias}}.NAME
     91     'minstd-shuffle'
     92 
     93 
     94 {{alias}}.MIN
     95     Minimum possible value.
     96 
     97     Examples
     98     --------
     99     > var v = {{alias}}.MIN
    100     1
    101 
    102 
    103 {{alias}}.MAX
    104     Maximum possible value.
    105 
    106     Examples
    107     --------
    108     > var v = {{alias}}.MAX
    109     2147483646
    110 
    111 
    112 {{alias}}.seed
    113     Pseudorandom number generator seed.
    114 
    115     Examples
    116     --------
    117     > var seed = {{alias}}.seed;
    118 
    119 
    120 {{alias}}.seedLength
    121     Length of generator seed.
    122 
    123     Examples
    124     --------
    125     > var len = {{alias}}.seedLength;
    126 
    127 
    128 {{alias}}.state
    129     Generator state.
    130 
    131     Examples
    132     --------
    133     > var r = {{alias}}()
    134     <number>
    135     > r = {{alias}}()
    136     <number>
    137     > r = {{alias}}()
    138     <number>
    139 
    140     // Get a copy of the current state:
    141     > var state = {{alias}}.state
    142     <Int32Array>
    143 
    144     > r = {{alias}}()
    145     <number>
    146     > r = {{alias}}()
    147     <number>
    148 
    149     // Set the state:
    150     > {{alias}}.state = state;
    151 
    152     // Replay the last two pseudorandom numbers:
    153     > r = {{alias}}()
    154     <number>
    155     > r = {{alias}}()
    156     <number>
    157 
    158 
    159 {{alias}}.stateLength
    160     Length of generator state.
    161 
    162     Examples
    163     --------
    164     > var len = {{alias}}.stateLength;
    165 
    166 
    167 {{alias}}.byteLength
    168     Size (in bytes) of generator state.
    169 
    170     Examples
    171     --------
    172     > var sz = {{alias}}.byteLength;
    173 
    174 
    175 {{alias}}.toJSON()
    176     Serializes the pseudorandom number generator as a JSON object.
    177 
    178     Returns
    179     -------
    180     out: Object
    181         JSON representation.
    182 
    183     Examples
    184     --------
    185     > var o = {{alias}}.toJSON()
    186     { 'type': 'PRNG', 'name': '...', 'state': {...}, 'params': [] }
    187 
    188     See Also
    189     --------
    190