Rand Monad and Random Class #
This module provides tools for formulating computations guided by randomness and for defining objects that can be created randomly.
Main definitions #
- RandTand- RandGTmonad transformers for computations guided by randomness;
- Randand- RandGmonads as special cases of the above
- Randomclass for objects that can be generated randomly;- randomto generate one object;
 
- BoundedRandomclass for objects that can be generated randomly inside a range;- randomRto generate one object inside a range;
 
- runRandto run a randomized computation inside any monad that has access to- stdGenRef.
References #
- Similar library in Haskell: https://hackage.haskell.org/package/MonadRandom
A monad to generate random objects using the generator type g.
Equations
Instances For
A monad to generate random objects using the generator type StdGen.
Equations
Instances For
Equations
- Plausible.instMonadLiftTRandGTOfMonadLift = { monadLift := fun {α : Type ?u.31} (x : Plausible.RandGT g m α) (s : ULift g) => liftM (x s) }
Random m α gives us machinery to generate values of type α in the monad m.
Note that m is a parameter as some types may only be sampleable with access to a certain monad.
- Generate a value of type - αrandomly using generator- g.
Instances
Given a random generator for α, we can convert it to a random generator for ULift α.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given a random generator for ULift α, we can convert it to a random generator for α.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Create a new random number generator distinct from the one stored in the state
Equations
Instances For
Given a random generator for α, we can convert it to a random generator for ULift α.
Equations
- Plausible.Rand.up x = Plausible.RandT.up (fun {α : Type ?u.25} (x : Id α) => pure { down := x.run }) x
Instances For
Given a random generator for ULift α, we can convert it to a random generator for α.
Equations
- Plausible.Rand.down x = Plausible.RandT.down (fun {α : Type ?u.25} (x : Id (ULift α)) => pure x.run.down) x
Instances For
Generate a random value of type α between x and y inclusive.
Equations
- Plausible.Random.randBound α lo hi h = Plausible.BoundedRandom.randomR lo hi h
Instances For
Equations
- Plausible.Random.instBool = { random := fun {g : Type} [RandomGen g] => Plausible.Random.randBool }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Computes a RandT m α using the global stdGenRef as RNG.
Note that:
- stdGenRefis not necessarily properly seeded on program startup as of now and will therefore be deterministic.
- stdGenRefis not thread local, hence two threads accessing it at the same time will get the exact same generator.
Equations
- One or more equations did not get rendered due to their size.