time-to-botec

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

repl.txt (4020B)


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