Generate a random Boolean.
9.9. 乱数(Random Numbers)
def
randNat.{u} {gen : Type u} [RandomGen gen] (g : gen) (lo hi : Nat) : Nat × gen
Generate a random natural number in the interval [lo, hi].
9.9.1. 乱数生成(Random Generators)
type class
RandomGen.{u} (g : Type u) : Type u
Interface for random number generators.
Instance Constructor
RandomGen.mk.{u}
Methods
range : g → Nat × Nat
range
returns the range of values returned by
the generator.
next : g → Nat × g
next
operation returns a natural number that is uniformly distributed
the range returned by range
(including both end points),
and a new generator.
split : g → g × g
The 'split' operation allows one to obtain two distinct random number generators. This is very useful in functional programs (for example, when passing a random number generator down to recursive calls).
structure
StdGen : Type