|
| 1 | +/// Type bindings for Python random module: https://docs.python.org/3/library/random.html |
| 2 | +module Fable.Python.Random |
| 3 | + |
| 4 | +open System.Collections.Generic |
| 5 | +open Fable.Core |
| 6 | + |
| 7 | +// fsharplint:disable MemberNames |
| 8 | + |
| 9 | +[<Erase>] |
| 10 | +type IExports = |
| 11 | + /// Initialize the random number generator |
| 12 | + /// See https://docs.python.org/3/library/random.html#random.seed |
| 13 | + [<Emit("$0.seed(int($1))")>] |
| 14 | + abstract seed: a: int -> unit |
| 15 | + /// Initialize the random number generator |
| 16 | + /// See https://docs.python.org/3/library/random.html#random.seed |
| 17 | + abstract seed: a: nativeint -> unit |
| 18 | + /// Initialize the random number generator |
| 19 | + /// See https://docs.python.org/3/library/random.html#random.seed |
| 20 | + abstract seed: a: float -> unit |
| 21 | + /// Initialize the random number generator |
| 22 | + /// See https://docs.python.org/3/library/random.html#random.seed |
| 23 | + abstract seed: a: string -> unit |
| 24 | + /// Initialize the random number generator with current time |
| 25 | + /// See https://docs.python.org/3/library/random.html#random.seed |
| 26 | + abstract seed: unit -> unit |
| 27 | + |
| 28 | + /// Return a random floating point number in the range [0.0, 1.0) |
| 29 | + /// See https://docs.python.org/3/library/random.html#random.random |
| 30 | + abstract random: unit -> float |
| 31 | + |
| 32 | + /// Return a random floating point number N such that a <= N <= b |
| 33 | + /// See https://docs.python.org/3/library/random.html#random.uniform |
| 34 | + abstract uniform: a: float * b: float -> float |
| 35 | + |
| 36 | + /// Return a random floating point number N such that low <= N <= high with triangular distribution |
| 37 | + /// See https://docs.python.org/3/library/random.html#random.triangular |
| 38 | + abstract triangular: low: float * high: float * mode: float -> float |
| 39 | + /// Return a random floating point number N such that 0 <= N <= 1 with triangular distribution |
| 40 | + /// See https://docs.python.org/3/library/random.html#random.triangular |
| 41 | + abstract triangular: unit -> float |
| 42 | + |
| 43 | + /// Return a random integer N such that a <= N <= b |
| 44 | + /// See https://docs.python.org/3/library/random.html#random.randint |
| 45 | + abstract randint: a: int * b: int -> int |
| 46 | + |
| 47 | + /// Return a randomly selected element from range(start, stop, step) |
| 48 | + /// See https://docs.python.org/3/library/random.html#random.randrange |
| 49 | + abstract randrange: stop: int -> int |
| 50 | + /// Return a randomly selected element from range(start, stop, step) |
| 51 | + /// See https://docs.python.org/3/library/random.html#random.randrange |
| 52 | + abstract randrange: start: int * stop: int -> int |
| 53 | + /// Return a randomly selected element from range(start, stop, step) |
| 54 | + /// See https://docs.python.org/3/library/random.html#random.randrange |
| 55 | + abstract randrange: start: int * stop: int * step: int -> int |
| 56 | + |
| 57 | + /// Return a random element from the non-empty sequence |
| 58 | + /// See https://docs.python.org/3/library/random.html#random.choice |
| 59 | + [<Emit("$0.choice(list($1))")>] |
| 60 | + abstract choice: seq: 'T[] -> 'T |
| 61 | + /// Return a random element from the non-empty sequence |
| 62 | + /// See https://docs.python.org/3/library/random.html#random.choice |
| 63 | + [<Emit("$0.choice(list($1))")>] |
| 64 | + abstract choice: seq: 'T list -> 'T |
| 65 | + /// Return a random element from the non-empty sequence |
| 66 | + /// See https://docs.python.org/3/library/random.html#random.choice |
| 67 | + abstract choice: seq: ResizeArray<'T> -> 'T |
| 68 | + |
| 69 | + /// Return a k length list of unique elements chosen from the population sequence |
| 70 | + /// See https://docs.python.org/3/library/random.html#random.sample |
| 71 | + [<Emit("$0.sample(list($1), int($2))")>] |
| 72 | + abstract sample: population: 'T[] * k: int -> ResizeArray<'T> |
| 73 | + /// Return a k length list of unique elements chosen from the population sequence |
| 74 | + /// See https://docs.python.org/3/library/random.html#random.sample |
| 75 | + [<Emit("$0.sample(list($1), int($2))")>] |
| 76 | + abstract sample: population: 'T list * k: int -> ResizeArray<'T> |
| 77 | + /// Return a k length list of unique elements chosen from the population sequence |
| 78 | + /// See https://docs.python.org/3/library/random.html#random.sample |
| 79 | + [<Emit("$0.sample($1, int($2))")>] |
| 80 | + abstract sample: population: ResizeArray<'T> * k: int -> ResizeArray<'T> |
| 81 | + |
| 82 | + /// Return a k sized list of elements chosen from the population with replacement |
| 83 | + /// See https://docs.python.org/3/library/random.html#random.choices |
| 84 | + [<Emit("$0.choices(list($1), k=int($2))")>] |
| 85 | + abstract choices: population: 'T[] * k: int -> ResizeArray<'T> |
| 86 | + /// Return a k sized list of elements chosen from the population with replacement |
| 87 | + /// See https://docs.python.org/3/library/random.html#random.choices |
| 88 | + [<Emit("$0.choices(list($1), k=int($2))")>] |
| 89 | + abstract choices: population: 'T list * k: int -> ResizeArray<'T> |
| 90 | + /// Return a k sized list of elements chosen from the population with replacement |
| 91 | + /// See https://docs.python.org/3/library/random.html#random.choices |
| 92 | + [<Emit("$0.choices($1, k=int($2))")>] |
| 93 | + abstract choices: population: ResizeArray<'T> * k: int -> ResizeArray<'T> |
| 94 | + |
| 95 | + /// Shuffle the sequence x in place |
| 96 | + /// See https://docs.python.org/3/library/random.html#random.shuffle |
| 97 | + abstract shuffle: x: 'T[] -> unit |
| 98 | + /// Shuffle the sequence x in place |
| 99 | + /// See https://docs.python.org/3/library/random.html#random.shuffle |
| 100 | + abstract shuffle: x: ResizeArray<'T> -> unit |
| 101 | + |
| 102 | + /// Return a random integer with k random bits |
| 103 | + /// See https://docs.python.org/3/library/random.html#random.getrandbits |
| 104 | + abstract getrandbits: k: int -> int |
| 105 | + |
| 106 | + /// Beta distribution |
| 107 | + /// See https://docs.python.org/3/library/random.html#random.betavariate |
| 108 | + abstract betavariate: alpha: float * beta: float -> float |
| 109 | + |
| 110 | + /// Exponential distribution |
| 111 | + /// See https://docs.python.org/3/library/random.html#random.expovariate |
| 112 | + abstract expovariate: lambd: float -> float |
| 113 | + |
| 114 | + /// Gamma distribution |
| 115 | + /// See https://docs.python.org/3/library/random.html#random.gammavariate |
| 116 | + abstract gammavariate: alpha: float * beta: float -> float |
| 117 | + |
| 118 | + /// Gaussian distribution (same as normalvariate but faster) |
| 119 | + /// See https://docs.python.org/3/library/random.html#random.gauss |
| 120 | + abstract gauss: mu: float * sigma: float -> float |
| 121 | + |
| 122 | + /// Log normal distribution |
| 123 | + /// See https://docs.python.org/3/library/random.html#random.lognormvariate |
| 124 | + abstract lognormvariate: mu: float * sigma: float -> float |
| 125 | + |
| 126 | + /// Normal distribution |
| 127 | + /// See https://docs.python.org/3/library/random.html#random.normalvariate |
| 128 | + abstract normalvariate: mu: float * sigma: float -> float |
| 129 | + |
| 130 | + /// Von Mises distribution |
| 131 | + /// See https://docs.python.org/3/library/random.html#random.vonmisesvariate |
| 132 | + abstract vonmisesvariate: mu: float * kappa: float -> float |
| 133 | + |
| 134 | + /// Pareto distribution |
| 135 | + /// See https://docs.python.org/3/library/random.html#random.paretovariate |
| 136 | + abstract paretovariate: alpha: float -> float |
| 137 | + |
| 138 | + /// Weibull distribution |
| 139 | + /// See https://docs.python.org/3/library/random.html#random.weibullvariate |
| 140 | + abstract weibullvariate: alpha: float * beta: float -> float |
| 141 | + |
| 142 | +/// Random variable generators |
| 143 | +[<ImportAll("random")>] |
| 144 | +let random: IExports = nativeOnly |
0 commit comments