time-to-botec

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

repl.txt (3963B)


      1 
      2 {{alias}}( p )
      3     Returns a pseudorandom number drawn from a Bernoulli distribution.
      4 
      5     If `p < 0` or `p > 1` or `p` is `NaN`, the function returns `NaN`.
      6 
      7     Parameters
      8     ----------
      9     p: number
     10         Success probability.
     11 
     12     Returns
     13     -------
     14     r: integer
     15         Pseudorandom number.
     16 
     17     Examples
     18     --------
     19     > var r = {{alias}}( 0.8 );
     20 
     21 
     22 {{alias}}.factory( [p, ][options] )
     23     Returns a pseudorandom number generator (PRNG) for generating pseudorandom
     24     numbers drawn from a Bernoulli distribution.
     25 
     26     If provided `p`, the returned PRNG returns random variates drawn from the
     27     specified distribution.
     28 
     29     If not provided `p`, the returned PRNG requires that `p` be provided at each
     30     invocation.
     31 
     32     Parameters
     33     ----------
     34     p: number (optional)
     35         Success probability.
     36 
     37     options: Object (optional)
     38         Options.
     39 
     40     options.prng: Function (optional)
     41         Pseudorandom number generator (PRNG) for generating uniformly
     42         distributed pseudorandom numbers on the interval `[0,1)`. If provided,
     43         the `state` and `seed` options are ignored. In order to seed the
     44         returned pseudorandom number generator, one must seed the provided
     45         `prng` (assuming the provided `prng` is seedable).
     46 
     47     options.seed: integer|ArrayLikeObject<integer> (optional)
     48         Pseudorandom number generator seed. The seed may be either a positive
     49         unsigned 32-bit integer or, for arbitrary length seeds, an array-like
     50         object containing unsigned 32-bit integers.
     51 
     52     options.state: Uint32Array (optional)
     53         Pseudorandom number generator state. If provided, the `seed` option is
     54         ignored.
     55 
     56     options.copy: boolean (optional)
     57         Boolean indicating whether to copy a provided pseudorandom number
     58         generator state. Setting this option to `false` allows sharing state
     59         between two or more pseudorandom number generators. Setting this option
     60         to `true` ensures that a returned generator has exclusive control over
     61         its internal state. Default: true.
     62 
     63     Returns
     64     -------
     65     rand: Function
     66         Pseudorandom number generator (PRNG).
     67 
     68     Examples
     69     --------
     70     // Basic usage:
     71     > var rand = {{alias}}.factory();
     72     > var r = rand( 0.3 );
     73     > r = rand( 0.59 );
     74 
     75     // Provide `p`:
     76     > rand = {{alias}}.factory( 0.3 );
     77     > r = rand();
     78     > r = rand();
     79 
     80 
     81 {{alias}}.NAME
     82     Generator name.
     83 
     84     Examples
     85     --------
     86     > var str = {{alias}}.NAME
     87     'bernoulli'
     88 
     89 
     90 {{alias}}.PRNG
     91     Underlying pseudorandom number generator.
     92 
     93     Examples
     94     --------
     95     > var prng = {{alias}}.PRNG;
     96 
     97 
     98 {{alias}}.seed
     99     Pseudorandom number generator seed.
    100 
    101     Examples
    102     --------
    103     > var seed = {{alias}}.seed;
    104 
    105 
    106 {{alias}}.seedLength
    107     Length of generator seed.
    108 
    109     Examples
    110     --------
    111     > var len = {{alias}}.seedLength;
    112 
    113 
    114 {{alias}}.state
    115     Generator state.
    116 
    117     Examples
    118     --------
    119     > var r = {{alias}}( 0.3 )
    120     <number>
    121     > r = {{alias}}( 0.3 )
    122     <number>
    123     > r = {{alias}}( 0.3 )
    124     <number>
    125 
    126     // Get a copy of the current state:
    127     > var state = {{alias}}.state
    128     <Uint32Array>
    129 
    130     > r = {{alias}}( 0.3 )
    131     <number>
    132     > r = {{alias}}( 0.3 )
    133     <number>
    134 
    135     // Set the state:
    136     > {{alias}}.state = state;
    137 
    138     // Replay the last two pseudorandom numbers:
    139     > r = {{alias}}( 0.3 )
    140     <number>
    141     > r = {{alias}}( 0.3 )
    142     <number>
    143 
    144 
    145 {{alias}}.stateLength
    146     Length of generator state.
    147 
    148     Examples
    149     --------
    150     > var len = {{alias}}.stateLength;
    151 
    152 
    153 {{alias}}.byteLength
    154     Size (in bytes) of generator state.
    155 
    156     Examples
    157     --------
    158     > var sz = {{alias}}.byteLength;
    159 
    160 
    161 {{alias}}.toJSON()
    162     Serializes the pseudorandom number generator as a JSON object.
    163 
    164     Returns
    165     -------
    166     out: Object
    167         JSON representation.
    168 
    169     Examples
    170     --------
    171     > var o = {{alias}}.toJSON()
    172     { 'type': 'PRNG', 'name': '...', 'state': {...}, 'params': [] }
    173 
    174     See Also
    175     --------
    176