time-to-botec

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

repl.txt (4215B)


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