random-fu-0.3.0.0: Random number generation
Safe HaskellNone
LanguageHaskell2010

Data.Random

Description

Flexible modeling and sampling of random variables.

The central abstraction in this library is the concept of a random variable. It is not fully formalized in the standard measure-theoretic language, but rather is informally defined as a "thing you can get random values out of". Different random variables may have different types of values they can return or the same types but different probabilities for each value they can return. The random values you get out of them are traditionally called "random variates".

Most imperative-language random number libraries are all about obtaining and manipulating random variates. This one is about defining, manipulating and sampling random variables. Computationally, the distinction is small and mostly just a matter of perspective, but from a program design perspective it provides both a powerfully composable abstraction and a very useful separation of concerns.

Abstract random variables as implemented by RVar are composable. They can be defined in a monadic / "imperative" style that amounts to manipulating variates, but with strict type-level isolation. Concrete random variables are also provided, but they do not compose as generically. The Distribution type class allows concrete random variables to "forget" their concreteness so that they can be composed. For examples of both, see the documentation for RVar and Distribution, as well as the code for any of the concrete distributions such as Uniform, Gamma, etc.

Both abstract and concrete random variables can be sampled (despite the types GHCi may list for the functions) by the functions in Data.Random.Sample.

Random variable sampling is done with regard to a generic basis of primitive random variables defined in Data.Random.Internal.Primitives. This basis is very low-level and the actual set of primitives is still fairly experimental, which is why it is in the "Internal" sub-heirarchy. User-defined variables should use the existing high-level variables such as Uniform and Normal rather than these basis variables. Data.Random.Source defines classes for entropy sources that provide implementations of these primitive variables. Several implementations are available in the Data.Random.Source.* modules.

Synopsis

Random variables

Abstract (RVar)

type RVar = RVarT Identity #

An opaque type modeling a "random variable" - a value which depends on the outcome of some random event. RVars can be conveniently defined by an imperative-looking style:

normalPair =  do
    u <- stdUniform
    t <- stdUniform
    let r = sqrt (-2 * log u)
        theta = (2 * pi) * t

        x = r * cos theta
        y = r * sin theta
    return (x,y)

OR by a more applicative style:

logNormal = exp <$> stdNormal

Once defined (in any style), there are several ways to sample RVars:

  • Using an immutable pseudo-random number generator that has an instance for RandomGen with StateT monad:
>>> import qualified Data.Random as Fu (uniform)
>>> import System.Random (mkStdGen)
>>> import Control.Monad.State (runState)
>>> runState (sampleStateRVar (Fu.uniform 1 (100 :: Integer))) (mkStdGen 2021)
(79,StdGen {unStdGen = SMGen 4687568268719557181 4805600293067301895})
  • Using a mutable pseud-random number generator that has an instance for StatefulGen with ReaderT monad.
>>> import qualified Data.Random as Fu (uniform)
>>> import System.Random.MWC (create)
>>> import Control.Monad.Reader (runReaderT)
>>> import qualified Data.Vector.Storable as VS
>>> initialize (VS.singleton 2021) >>= runReaderT (sampleReaderRVar (uniform 1 (100 :: Integer)))
8

data RVarT (m :: Type -> Type) a #

A random variable with access to operations in an underlying monad. Useful examples include any form of state for implementing random processes with hysteresis, or writer monads for implementing tracing of complicated algorithms.

For example, a simple random walk can be implemented as an RVarT IO value:

rwalkIO :: IO (RVarT IO Double)
rwalkIO d = do
    lastVal <- newIORef 0

    let x = do
            prev    <- lift (readIORef lastVal)
            change  <- rvarT StdNormal

            let new = prev + change
            lift (writeIORef lastVal new)
            return new

    return x

To run the random walk it must first be initialized, after which it can be sampled as usual:

do
    rw <- rwalkIO
    x <- sampleRVarT rw
    y <- sampleRVarT rw
    ...

The same random-walk process as above can be implemented using MTL types as follows (using import Control.Monad.Trans as MTL):

rwalkState :: RVarT (State Double) Double
rwalkState = do
    prev <- MTL.lift get
    change  <- rvarT StdNormal

    let new = prev + change
    MTL.lift (put new)
    return new

Invocation is straightforward (although a bit noisy) if you're used to MTL:

rwalk :: Int -> Double -> StdGen -> ([Double], StdGen)
rwalk count start gen =
    flip evalState start .
        flip runStateT gen .
            sampleRVarTWith MTL.lift $
                replicateM count rwalkState

Instances

Instances details
MonadTrans RVarT 
Instance details

Defined in Data.RVar

Methods

lift :: Monad m => m a -> RVarT m a #

MonadPrompt Prim (RVarT n) 
Instance details

Defined in Data.RVar

Methods

prompt :: Prim a -> RVarT n a #

StatefulGen RGen (RVarT m) 
Instance details

Defined in Data.RVar

Monad (RVarT n) 
Instance details

Defined in Data.RVar

Methods

(>>=) :: RVarT n a -> (a -> RVarT n b) -> RVarT n b #

(>>) :: RVarT n a -> RVarT n b -> RVarT n b #

return :: a -> RVarT n a #

Functor (RVarT n) 
Instance details

Defined in Data.RVar

Methods

fmap :: (a -> b) -> RVarT n a -> RVarT n b #

(<$) :: a -> RVarT n b -> RVarT n a #

Applicative (RVarT n) 
Instance details

Defined in Data.RVar

Methods

pure :: a -> RVarT n a #

(<*>) :: RVarT n (a -> b) -> RVarT n a -> RVarT n b #

liftA2 :: (a -> b -> c) -> RVarT n a -> RVarT n b -> RVarT n c #

(*>) :: RVarT n a -> RVarT n b -> RVarT n b #

(<*) :: RVarT n a -> RVarT n b -> RVarT n a #

MonadIO m => MonadIO (RVarT m) 
Instance details

Defined in Data.RVar

Methods

liftIO :: IO a -> RVarT m a #

Lift m n => Sampleable (RVarT m) n t Source # 
Instance details

Defined in Data.Random.Sample

Methods

sampleFrom :: StatefulGen g n => g -> RVarT m t -> n t Source #

Lift (RVarT Identity) (RVarT m) Source # 
Instance details

Defined in Data.Random.Lift

Methods

lift :: RVarT Identity a -> RVarT m a Source #

runRVar :: StatefulGen g m => RVar a -> g -> m a #

"Run" an RVar - samples the random variable from the provided source of entropy.

runRVarT :: (Lift n m, StatefulGen g m) => RVarT n a -> g -> m a Source #

Like runRVarTWith, but using an implicit lifting (provided by the Lift class)

runRVarTWith :: forall m n g a. StatefulGen g m => (forall t. n t -> m t) -> RVarT n a -> g -> m a #

"Runs" an RVarT, sampling the random variable it defines.

The first argument lifts the base monad into the sampling monad. This operation must obey the "monad transformer" laws:

lift . return = return
lift (x >>= f) = (lift x) >>= (lift . f)

One example of a useful non-standard lifting would be one that takes State s to another monad with a different state representation (such as IO with the state mapped to an IORef):

embedState :: (Monad m) => m s -> (s -> m ()) -> State s a -> m a
embedState get put = \m -> do
    s <- get
    (res,s) <- return (runState m s)
    put s
    return res

The ability to lift is very important - without it, every RVar would have to either be given access to the full capability of the monad in which it will eventually be sampled (which, incidentally, would also have to be monomorphic so you couldn't sample one RVar in more than one monad) or functions manipulating RVars would have to use higher-ranked types to enforce the same kind of isolation and polymorphism.

Concrete (Distribution)

class Distribution d t where Source #

A Distribution is a data representation of a random variable's probability structure. For example, in Data.Random.Distribution.Normal, the Normal distribution is defined as:

data Normal a
    = StdNormal
    | Normal a a

Where the two parameters of the Normal data constructor are the mean and standard deviation of the random variable, respectively. To make use of the Normal type, one can convert it to an rvar and manipulate it or sample it directly:

x <- sample (rvar (Normal 10 2))
x <- sample (Normal 10 2)

A Distribution is typically more transparent than an RVar but less composable (precisely because of that transparency). There are several practical uses for types implementing Distribution:

  • Typically, a Distribution will expose several parameters of a standard mathematical model of a probability distribution, such as mean and std deviation for the normal distribution. Thus, they can be manipulated analytically using mathematical insights about the distributions they represent. For example, a collection of bernoulli variables could be simplified into a (hopefully) smaller collection of binomial variables.
  • Because they are generally just containers for parameters, they can be easily serialized to persistent storage or read from user-supplied configurations (eg, initialization data for a simulation).
  • If a type additionally implements the CDF subclass, which extends Distribution with a cumulative density function, an arbitrary random variable x can be tested against the distribution by testing fmap (cdf dist) x for uniformity.

On the other hand, most Distributions will not be closed under all the same operations as RVar (which, being a monad, has a fully turing-complete internal computational model). The sum of two uniformly-distributed variables, for example, is not uniformly distributed. To support general composition, the Distribution class defines a function rvar to construct the more-abstract and more-composable RVar representation of a random variable.

Minimal complete definition

Nothing

Methods

rvar :: d t -> RVar t Source #

Return a random variable with this distribution.

rvarT :: d t -> RVarT n t Source #

Return a random variable with the given distribution, pre-lifted to an arbitrary RVarT. Any arbitrary RVar can also be converted to an 'RVarT m' for an arbitrary m, using either lift or sample.

Instances

Instances details
Distribution StdUniform Bool Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform Bool -> RVar Bool Source #

rvarT :: forall (n :: Type -> Type). StdUniform Bool -> RVarT n Bool Source #

Distribution StdUniform Char Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform Char -> RVar Char Source #

rvarT :: forall (n :: Type -> Type). StdUniform Char -> RVarT n Char Source #

Distribution StdUniform Double Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Float Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Int Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform Int -> RVar Int Source #

rvarT :: forall (n :: Type -> Type). StdUniform Int -> RVarT n Int Source #

Distribution StdUniform Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform Int8 -> RVar Int8 Source #

rvarT :: forall (n :: Type -> Type). StdUniform Int8 -> RVarT n Int8 Source #

Distribution StdUniform Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Ordering Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Word Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform Word -> RVar Word Source #

rvarT :: forall (n :: Type -> Type). StdUniform Word -> RVarT n Word Source #

Distribution StdUniform Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform () Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform () -> RVar () Source #

rvarT :: forall (n :: Type -> Type). StdUniform () -> RVarT n () Source #

Distribution Uniform Bool Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Bool -> RVar Bool Source #

rvarT :: forall (n :: Type -> Type). Uniform Bool -> RVarT n Bool Source #

Distribution Uniform Char Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Char -> RVar Char Source #

rvarT :: forall (n :: Type -> Type). Uniform Char -> RVarT n Char Source #

Distribution Uniform Double Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Double -> RVar Double Source #

rvarT :: forall (n :: Type -> Type). Uniform Double -> RVarT n Double Source #

Distribution Uniform Float Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Float -> RVar Float Source #

rvarT :: forall (n :: Type -> Type). Uniform Float -> RVarT n Float Source #

Distribution Uniform Int Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Int -> RVar Int Source #

rvarT :: forall (n :: Type -> Type). Uniform Int -> RVarT n Int Source #

Distribution Uniform Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Int8 -> RVar Int8 Source #

rvarT :: forall (n :: Type -> Type). Uniform Int8 -> RVarT n Int8 Source #

Distribution Uniform Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Int16 -> RVar Int16 Source #

rvarT :: forall (n :: Type -> Type). Uniform Int16 -> RVarT n Int16 Source #

Distribution Uniform Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Int32 -> RVar Int32 Source #

rvarT :: forall (n :: Type -> Type). Uniform Int32 -> RVarT n Int32 Source #

Distribution Uniform Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Int64 -> RVar Int64 Source #

rvarT :: forall (n :: Type -> Type). Uniform Int64 -> RVarT n Int64 Source #

Distribution Uniform Integer Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution Uniform Ordering Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution Uniform Word Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Word -> RVar Word Source #

rvarT :: forall (n :: Type -> Type). Uniform Word -> RVarT n Word Source #

Distribution Uniform Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Word8 -> RVar Word8 Source #

rvarT :: forall (n :: Type -> Type). Uniform Word8 -> RVarT n Word8 Source #

Distribution Uniform Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Word16 -> RVar Word16 Source #

rvarT :: forall (n :: Type -> Type). Uniform Word16 -> RVarT n Word16 Source #

Distribution Uniform Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Word32 -> RVar Word32 Source #

rvarT :: forall (n :: Type -> Type). Uniform Word32 -> RVarT n Word32 Source #

Distribution Uniform Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Word64 -> RVar Word64 Source #

rvarT :: forall (n :: Type -> Type). Uniform Word64 -> RVarT n Word64 Source #

Distribution Uniform () Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform () -> RVar () Source #

rvarT :: forall (n :: Type -> Type). Uniform () -> RVarT n () Source #

(Floating a, Distribution StdUniform a) => Distribution Weibull a Source # 
Instance details

Defined in Data.Random.Distribution.Weibull

Methods

rvar :: Weibull a -> RVar a Source #

rvarT :: forall (n :: Type -> Type). Weibull a -> RVarT n a Source #

(RealFloat a, Ord a, Distribution StdUniform a) => Distribution Triangular a Source # 
Instance details

Defined in Data.Random.Distribution.Triangular

Methods

rvar :: Triangular a -> RVar a Source #

rvarT :: forall (n :: Type -> Type). Triangular a -> RVarT n a Source #

(Floating a, Distribution StdUniform a) => Distribution StretchedExponential a Source # 
Instance details

Defined in Data.Random.Distribution.StretchedExponential

Methods

rvar :: StretchedExponential a -> RVar a Source #

rvarT :: forall (n :: Type -> Type). StretchedExponential a -> RVarT n a Source #

(RealFloat a, Distribution StdUniform a) => Distribution Rayleigh a Source # 
Instance details

Defined in Data.Random.Distribution.Rayleigh

Methods

rvar :: Rayleigh a -> RVar a Source #

rvarT :: forall (n :: Type -> Type). Rayleigh a -> RVarT n a Source #

Distribution Normal Double Source # 
Instance details

Defined in Data.Random.Distribution.Normal

Methods

rvar :: Normal Double -> RVar Double Source #

rvarT :: forall (n :: Type -> Type). Normal Double -> RVarT n Double Source #

Distribution Normal Float Source # 
Instance details

Defined in Data.Random.Distribution.Normal

Methods

rvar :: Normal Float -> RVar Float Source #

rvarT :: forall (n :: Type -> Type). Normal Float -> RVarT n Float Source #

(Floating a, Ord a, Distribution Normal a, Distribution StdUniform a) => Distribution Gamma a Source # 
Instance details

Defined in Data.Random.Distribution.Gamma

Methods

rvar :: Gamma a -> RVar a Source #

rvarT :: forall (n :: Type -> Type). Gamma a -> RVarT n a Source #

(Floating a, Distribution StdUniform a) => Distribution Exponential a Source # 
Instance details

Defined in Data.Random.Distribution.Exponential

Methods

rvar :: Exponential a -> RVar a Source #

rvarT :: forall (n :: Type -> Type). Exponential a -> RVarT n a Source #

(Fractional t, Distribution Gamma t) => Distribution ChiSquare t Source # 
Instance details

Defined in Data.Random.Distribution.ChiSquare

Methods

rvar :: ChiSquare t -> RVar t Source #

rvarT :: forall (n :: Type -> Type). ChiSquare t -> RVarT n t Source #

(Floating a, Distribution Normal a, Distribution ChiSquare a) => Distribution T a Source # 
Instance details

Defined in Data.Random.Distribution.T

Methods

rvar :: T a -> RVar a Source #

rvarT :: forall (n :: Type -> Type). T a -> RVarT n a Source #

Distribution Beta Double Source # 
Instance details

Defined in Data.Random.Distribution.Beta

Methods

rvar :: Beta Double -> RVar Double Source #

rvarT :: forall (n :: Type -> Type). Beta Double -> RVarT n Double Source #

Distribution Beta Float Source # 
Instance details

Defined in Data.Random.Distribution.Beta

Methods

rvar :: Beta Float -> RVar Float Source #

rvarT :: forall (n :: Type -> Type). Beta Float -> RVarT n Float Source #

(Floating a, Distribution StdUniform a) => Distribution Pareto a Source # 
Instance details

Defined in Data.Random.Distribution.Pareto

Methods

rvar :: Pareto a -> RVar a Source #

rvarT :: forall (n :: Type -> Type). Pareto a -> RVarT n a Source #

(Ord a, Fractional a, Distribution StdUniform a) => Distribution StdSimplex [a] Source # 
Instance details

Defined in Data.Random.Distribution.Simplex

Methods

rvar :: StdSimplex [a] -> RVar [a] Source #

rvarT :: forall (n :: Type -> Type). StdSimplex [a] -> RVarT n [a] Source #

(Fractional a, Distribution Gamma a) => Distribution Dirichlet [a] Source # 
Instance details

Defined in Data.Random.Distribution.Dirichlet

Methods

rvar :: Dirichlet [a] -> RVar [a] Source #

rvarT :: forall (n :: Type -> Type). Dirichlet [a] -> RVarT n [a] Source #

HasResolution r => Distribution StdUniform (Fixed r) Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform (Fixed r) -> RVar (Fixed r) Source #

rvarT :: forall (n :: Type -> Type). StdUniform (Fixed r) -> RVarT n (Fixed r) Source #

HasResolution r => Distribution Uniform (Fixed r) Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform (Fixed r) -> RVar (Fixed r) Source #

rvarT :: forall (n :: Type -> Type). Uniform (Fixed r) -> RVarT n (Fixed r) Source #

(Num t, Ord t, Vector v t) => Distribution (Ziggurat v) t Source # 
Instance details

Defined in Data.Random.Distribution.Ziggurat

Methods

rvar :: Ziggurat v t -> RVar t Source #

rvarT :: forall (n :: Type -> Type). Ziggurat v t -> RVarT n t Source #

(Integral a, Floating b, Ord b, Distribution Normal b, Distribution StdUniform b) => Distribution (Erlang a) b Source # 
Instance details

Defined in Data.Random.Distribution.Gamma

Methods

rvar :: Erlang a b -> RVar b Source #

rvarT :: forall (n :: Type -> Type). Erlang a b -> RVarT n b Source #

(Fractional p, Ord p, Distribution Uniform p) => Distribution (Categorical p) a Source # 
Instance details

Defined in Data.Random.Distribution.Categorical

Methods

rvar :: Categorical p a -> RVar a Source #

rvarT :: forall (n :: Type -> Type). Categorical p a -> RVarT n a Source #

Distribution (Binomial b) Integer => Distribution (Binomial b) Double Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Double -> RVar Double Source #

rvarT :: forall (n :: Type -> Type). Binomial b Double -> RVarT n Double Source #

Distribution (Binomial b) Integer => Distribution (Binomial b) Float Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Float -> RVar Float Source #

rvarT :: forall (n :: Type -> Type). Binomial b Float -> RVarT n Float Source #

(Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => Distribution (Binomial b) Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Word64 -> RVar Word64 Source #

rvarT :: forall (n :: Type -> Type). Binomial b Word64 -> RVarT n Word64 Source #

(Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => Distribution (Binomial b) Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Word32 -> RVar Word32 Source #

rvarT :: forall (n :: Type -> Type). Binomial b Word32 -> RVarT n Word32 Source #

(Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => Distribution (Binomial b) Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Word16 -> RVar Word16 Source #

rvarT :: forall (n :: Type -> Type). Binomial b Word16 -> RVarT n Word16 Source #

(Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => Distribution (Binomial b) Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Word8 -> RVar Word8 Source #

rvarT :: forall (n :: Type -> Type). Binomial b Word8 -> RVarT n Word8 Source #

(Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => Distribution (Binomial b) Word Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Word -> RVar Word Source #

rvarT :: forall (n :: Type -> Type). Binomial b Word -> RVarT n Word Source #

(Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => Distribution (Binomial b) Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Int64 -> RVar Int64 Source #

rvarT :: forall (n :: Type -> Type). Binomial b Int64 -> RVarT n Int64 Source #

(Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => Distribution (Binomial b) Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Int32 -> RVar Int32 Source #

rvarT :: forall (n :: Type -> Type). Binomial b Int32 -> RVarT n Int32 Source #

(Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => Distribution (Binomial b) Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Int16 -> RVar Int16 Source #

rvarT :: forall (n :: Type -> Type). Binomial b Int16 -> RVarT n Int16 Source #

(Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => Distribution (Binomial b) Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Int8 -> RVar Int8 Source #

rvarT :: forall (n :: Type -> Type). Binomial b Int8 -> RVarT n Int8 Source #

(Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => Distribution (Binomial b) Int Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Int -> RVar Int Source #

rvarT :: forall (n :: Type -> Type). Binomial b Int -> RVarT n Int Source #

(Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => Distribution (Binomial b) Integer Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

rvar :: Binomial b Integer -> RVar Integer Source #

rvarT :: forall (n :: Type -> Type). Binomial b Integer -> RVarT n Integer Source #

Distribution (Poisson b) Integer => Distribution (Poisson b) Double Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Double -> RVar Double Source #

rvarT :: forall (n :: Type -> Type). Poisson b Double -> RVarT n Double Source #

Distribution (Poisson b) Integer => Distribution (Poisson b) Float Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Float -> RVar Float Source #

rvarT :: forall (n :: Type -> Type). Poisson b Float -> RVarT n Float Source #

(RealFloat b, Distribution StdUniform b, Distribution (Erlang Word64) b, Distribution (Binomial b) Word64) => Distribution (Poisson b) Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Word64 -> RVar Word64 Source #

rvarT :: forall (n :: Type -> Type). Poisson b Word64 -> RVarT n Word64 Source #

(RealFloat b, Distribution StdUniform b, Distribution (Erlang Word32) b, Distribution (Binomial b) Word32) => Distribution (Poisson b) Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Word32 -> RVar Word32 Source #

rvarT :: forall (n :: Type -> Type). Poisson b Word32 -> RVarT n Word32 Source #

(RealFloat b, Distribution StdUniform b, Distribution (Erlang Word16) b, Distribution (Binomial b) Word16) => Distribution (Poisson b) Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Word16 -> RVar Word16 Source #

rvarT :: forall (n :: Type -> Type). Poisson b Word16 -> RVarT n Word16 Source #

(RealFloat b, Distribution StdUniform b, Distribution (Erlang Word8) b, Distribution (Binomial b) Word8) => Distribution (Poisson b) Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Word8 -> RVar Word8 Source #

rvarT :: forall (n :: Type -> Type). Poisson b Word8 -> RVarT n Word8 Source #

(RealFloat b, Distribution StdUniform b, Distribution (Erlang Word) b, Distribution (Binomial b) Word) => Distribution (Poisson b) Word Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Word -> RVar Word Source #

rvarT :: forall (n :: Type -> Type). Poisson b Word -> RVarT n Word Source #

(RealFloat b, Distribution StdUniform b, Distribution (Erlang Int64) b, Distribution (Binomial b) Int64) => Distribution (Poisson b) Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Int64 -> RVar Int64 Source #

rvarT :: forall (n :: Type -> Type). Poisson b Int64 -> RVarT n Int64 Source #

(RealFloat b, Distribution StdUniform b, Distribution (Erlang Int32) b, Distribution (Binomial b) Int32) => Distribution (Poisson b) Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Int32 -> RVar Int32 Source #

rvarT :: forall (n :: Type -> Type). Poisson b Int32 -> RVarT n Int32 Source #

(RealFloat b, Distribution StdUniform b, Distribution (Erlang Int16) b, Distribution (Binomial b) Int16) => Distribution (Poisson b) Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Int16 -> RVar Int16 Source #

rvarT :: forall (n :: Type -> Type). Poisson b Int16 -> RVarT n Int16 Source #

(RealFloat b, Distribution StdUniform b, Distribution (Erlang Int8) b, Distribution (Binomial b) Int8) => Distribution (Poisson b) Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Int8 -> RVar Int8 Source #

rvarT :: forall (n :: Type -> Type). Poisson b Int8 -> RVarT n Int8 Source #

(RealFloat b, Distribution StdUniform b, Distribution (Erlang Int) b, Distribution (Binomial b) Int) => Distribution (Poisson b) Int Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Int -> RVar Int Source #

rvarT :: forall (n :: Type -> Type). Poisson b Int -> RVarT n Int Source #

(RealFloat b, Distribution StdUniform b, Distribution (Erlang Integer) b, Distribution (Binomial b) Integer) => Distribution (Poisson b) Integer Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

rvar :: Poisson b Integer -> RVar Integer Source #

rvarT :: forall (n :: Type -> Type). Poisson b Integer -> RVarT n Integer Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Double Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Double -> RVar Double Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Double -> RVarT n Double Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Float Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Float -> RVar Float Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Float -> RVarT n Float Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Word64 -> RVar Word64 Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Word64 -> RVarT n Word64 Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Word32 -> RVar Word32 Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Word32 -> RVarT n Word32 Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Word16 -> RVar Word16 Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Word16 -> RVarT n Word16 Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Word8 -> RVar Word8 Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Word8 -> RVarT n Word8 Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Word Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Word -> RVar Word Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Word -> RVarT n Word Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Int64 -> RVar Int64 Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Int64 -> RVarT n Int64 Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Int32 -> RVar Int32 Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Int32 -> RVarT n Int32 Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Int16 -> RVar Int16 Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Int16 -> RVarT n Int16 Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Int8 -> RVar Int8 Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Int8 -> RVarT n Int8 Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Int Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Int -> RVar Int Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Int -> RVarT n Int Source #

Distribution (Bernoulli b) Bool => Distribution (Bernoulli b) Integer Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

(Fractional b, Ord b, Distribution StdUniform b) => Distribution (Bernoulli b) Bool Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b Bool -> RVar Bool Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b Bool -> RVarT n Bool Source #

(Num a, Eq a, Fractional p, Distribution (Binomial p) a) => Distribution (Multinomial p) [a] Source # 
Instance details

Defined in Data.Random.Distribution.Multinomial

Methods

rvar :: Multinomial p [a] -> RVar [a] Source #

rvarT :: forall (n :: Type -> Type). Multinomial p [a] -> RVarT n [a] Source #

(Distribution (Bernoulli b) Bool, RealFloat a) => Distribution (Bernoulli b) (Complex a) Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b (Complex a) -> RVar (Complex a) Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b (Complex a) -> RVarT n (Complex a) Source #

(Distribution (Bernoulli b) Bool, Integral a) => Distribution (Bernoulli b) (Ratio a) Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

rvar :: Bernoulli b (Ratio a) -> RVar (Ratio a) Source #

rvarT :: forall (n :: Type -> Type). Bernoulli b (Ratio a) -> RVarT n (Ratio a) Source #

class Distribution d t => CDF d t where Source #

Methods

cdf :: d t -> t -> Double Source #

Return the cumulative distribution function of this distribution. That is, a function taking x :: t to the probability that the next sample will return a value less than or equal to x, according to some order or partial order (not necessarily an obvious one).

In the case where t is an instance of Ord, cdf should correspond to the CDF with respect to that order.

In other cases, cdf is only required to satisfy the following law: fmap (cdf d) (rvar d) must be uniformly distributed over (0,1). Inclusion of either endpoint is optional, though the preferred range is (0,1].

Note that this definition requires that cdf for a product type should _not_ be a joint CDF as commonly defined, as that definition violates both conditions. Instead, it should be a univariate CDF over the product type. That is, it should represent the CDF with respect to the lexicographic order of the product.

The present specification is probably only really useful for testing conformance of a variable to its target distribution, and I am open to suggestions for more-useful specifications (especially with regard to the interaction with product types).

Instances

Instances details
CDF StdUniform Bool Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Char Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Double Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Float Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Int Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: StdUniform Int -> Int -> Double Source #

CDF StdUniform Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Ordering Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Word Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform () Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: StdUniform () -> () -> Double Source #

CDF Uniform Bool Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Bool -> Bool -> Double Source #

CDF Uniform Char Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Char -> Char -> Double Source #

CDF Uniform Double Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform Float Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Float -> Float -> Double Source #

CDF Uniform Int Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Int -> Int -> Double Source #

CDF Uniform Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Int8 -> Int8 -> Double Source #

CDF Uniform Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Int16 -> Int16 -> Double Source #

CDF Uniform Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Int32 -> Int32 -> Double Source #

CDF Uniform Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Int64 -> Int64 -> Double Source #

CDF Uniform Integer Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform Ordering Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform Word Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Word -> Word -> Double Source #

CDF Uniform Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Word8 -> Word8 -> Double Source #

CDF Uniform Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform () Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform () -> () -> Double Source #

(Real a, Distribution Weibull a) => CDF Weibull a Source # 
Instance details

Defined in Data.Random.Distribution.Weibull

Methods

cdf :: Weibull a -> a -> Double Source #

(RealFrac a, Distribution Triangular a) => CDF Triangular a Source # 
Instance details

Defined in Data.Random.Distribution.Triangular

Methods

cdf :: Triangular a -> a -> Double Source #

(Real a, Distribution StretchedExponential a) => CDF StretchedExponential a Source # 
Instance details

Defined in Data.Random.Distribution.StretchedExponential

Methods

cdf :: StretchedExponential a -> a -> Double Source #

(Real a, Distribution Rayleigh a) => CDF Rayleigh a Source # 
Instance details

Defined in Data.Random.Distribution.Rayleigh

Methods

cdf :: Rayleigh a -> a -> Double Source #

(Real a, Distribution Normal a) => CDF Normal a Source # 
Instance details

Defined in Data.Random.Distribution.Normal

Methods

cdf :: Normal a -> a -> Double Source #

(Real a, Distribution Gamma a) => CDF Gamma a Source # 
Instance details

Defined in Data.Random.Distribution.Gamma

Methods

cdf :: Gamma a -> a -> Double Source #

(Real a, Distribution Exponential a) => CDF Exponential a Source # 
Instance details

Defined in Data.Random.Distribution.Exponential

Methods

cdf :: Exponential a -> a -> Double Source #

(Real t, Distribution ChiSquare t) => CDF ChiSquare t Source # 
Instance details

Defined in Data.Random.Distribution.ChiSquare

Methods

cdf :: ChiSquare t -> t -> Double Source #

(Real a, Distribution T a) => CDF T a Source # 
Instance details

Defined in Data.Random.Distribution.T

Methods

cdf :: T a -> a -> Double Source #

(Real a, Distribution Pareto a) => CDF Pareto a Source # 
Instance details

Defined in Data.Random.Distribution.Pareto

Methods

cdf :: Pareto a -> a -> Double Source #

HasResolution r => CDF StdUniform (Fixed r) Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: StdUniform (Fixed r) -> Fixed r -> Double Source #

HasResolution r => CDF Uniform (Fixed r) Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform (Fixed r) -> Fixed r -> Double Source #

(Integral a, Real b, Distribution (Erlang a) b) => CDF (Erlang a) b Source # 
Instance details

Defined in Data.Random.Distribution.Gamma

Methods

cdf :: Erlang a b -> b -> Double Source #

CDF (Binomial b) Integer => CDF (Binomial b) Double Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Double -> Double -> Double Source #

CDF (Binomial b) Integer => CDF (Binomial b) Float Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Float -> Float -> Double Source #

(Real b, Distribution (Binomial b) Word64) => CDF (Binomial b) Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Word64 -> Word64 -> Double Source #

(Real b, Distribution (Binomial b) Word32) => CDF (Binomial b) Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Word32 -> Word32 -> Double Source #

(Real b, Distribution (Binomial b) Word16) => CDF (Binomial b) Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Word16 -> Word16 -> Double Source #

(Real b, Distribution (Binomial b) Word8) => CDF (Binomial b) Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Word8 -> Word8 -> Double Source #

(Real b, Distribution (Binomial b) Word) => CDF (Binomial b) Word Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Word -> Word -> Double Source #

(Real b, Distribution (Binomial b) Int64) => CDF (Binomial b) Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Int64 -> Int64 -> Double Source #

(Real b, Distribution (Binomial b) Int32) => CDF (Binomial b) Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Int32 -> Int32 -> Double Source #

(Real b, Distribution (Binomial b) Int16) => CDF (Binomial b) Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Int16 -> Int16 -> Double Source #

(Real b, Distribution (Binomial b) Int8) => CDF (Binomial b) Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Int8 -> Int8 -> Double Source #

(Real b, Distribution (Binomial b) Int) => CDF (Binomial b) Int Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

Methods

cdf :: Binomial b Int -> Int -> Double Source #

(Real b, Distribution (Binomial b) Integer) => CDF (Binomial b) Integer Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

CDF (Poisson b) Integer => CDF (Poisson b) Double Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Double -> Double -> Double Source #

CDF (Poisson b) Integer => CDF (Poisson b) Float Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Float -> Float -> Double Source #

(Real b, Distribution (Poisson b) Word64) => CDF (Poisson b) Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Word64 -> Word64 -> Double Source #

(Real b, Distribution (Poisson b) Word32) => CDF (Poisson b) Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Word32 -> Word32 -> Double Source #

(Real b, Distribution (Poisson b) Word16) => CDF (Poisson b) Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Word16 -> Word16 -> Double Source #

(Real b, Distribution (Poisson b) Word8) => CDF (Poisson b) Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Word8 -> Word8 -> Double Source #

(Real b, Distribution (Poisson b) Word) => CDF (Poisson b) Word Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Word -> Word -> Double Source #

(Real b, Distribution (Poisson b) Int64) => CDF (Poisson b) Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Int64 -> Int64 -> Double Source #

(Real b, Distribution (Poisson b) Int32) => CDF (Poisson b) Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Int32 -> Int32 -> Double Source #

(Real b, Distribution (Poisson b) Int16) => CDF (Poisson b) Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Int16 -> Int16 -> Double Source #

(Real b, Distribution (Poisson b) Int8) => CDF (Poisson b) Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Int8 -> Int8 -> Double Source #

(Real b, Distribution (Poisson b) Int) => CDF (Poisson b) Int Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

cdf :: Poisson b Int -> Int -> Double Source #

(Real b, Distribution (Poisson b) Integer) => CDF (Poisson b) Integer Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Double Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Float Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

cdf :: Bernoulli b Float -> Float -> Double Source #

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

cdf :: Bernoulli b Word8 -> Word8 -> Double Source #

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Word Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

cdf :: Bernoulli b Word -> Word -> Double Source #

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

cdf :: Bernoulli b Int64 -> Int64 -> Double Source #

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

cdf :: Bernoulli b Int32 -> Int32 -> Double Source #

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

cdf :: Bernoulli b Int16 -> Int16 -> Double Source #

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

cdf :: Bernoulli b Int8 -> Int8 -> Double Source #

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Int Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

cdf :: Bernoulli b Int -> Int -> Double Source #

CDF (Bernoulli b) Bool => CDF (Bernoulli b) Integer Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

(Distribution (Bernoulli b) Bool, Real b) => CDF (Bernoulli b) Bool Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

cdf :: Bernoulli b Bool -> Bool -> Double Source #

(CDF (Bernoulli b) Bool, RealFloat a) => CDF (Bernoulli b) (Complex a) Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

cdf :: Bernoulli b (Complex a) -> Complex a -> Double Source #

(CDF (Bernoulli b) Bool, Integral a) => CDF (Bernoulli b) (Ratio a) Source # 
Instance details

Defined in Data.Random.Distribution.Bernoulli

Methods

cdf :: Bernoulli b (Ratio a) -> Ratio a -> Double Source #

class Distribution d t => PDF d t where Source #

Minimal complete definition

Nothing

Methods

pdf :: d t -> t -> Double Source #

logPdf :: d t -> t -> Double Source #

Instances

Instances details
PDF StdUniform Double Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

PDF StdUniform Float Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

(Real a, Floating a, Distribution Normal a) => PDF Normal a Source # 
Instance details

Defined in Data.Random.Distribution.Normal

Methods

pdf :: Normal a -> a -> Double Source #

logPdf :: Normal a -> a -> Double Source #

PDF Beta Double Source # 
Instance details

Defined in Data.Random.Distribution.Beta

PDF Beta Float Source # 
Instance details

Defined in Data.Random.Distribution.Beta

PDF (Binomial b) Integer => PDF (Binomial b) Double Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

PDF (Binomial b) Integer => PDF (Binomial b) Float Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

(Real b, Distribution (Binomial b) Word64) => PDF (Binomial b) Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

(Real b, Distribution (Binomial b) Word32) => PDF (Binomial b) Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

(Real b, Distribution (Binomial b) Word16) => PDF (Binomial b) Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

(Real b, Distribution (Binomial b) Word8) => PDF (Binomial b) Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

(Real b, Distribution (Binomial b) Word) => PDF (Binomial b) Word Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

(Real b, Distribution (Binomial b) Int64) => PDF (Binomial b) Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

(Real b, Distribution (Binomial b) Int32) => PDF (Binomial b) Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

(Real b, Distribution (Binomial b) Int16) => PDF (Binomial b) Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

(Real b, Distribution (Binomial b) Int8) => PDF (Binomial b) Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

(Real b, Distribution (Binomial b) Int) => PDF (Binomial b) Int Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

(Real b, Distribution (Binomial b) Integer) => PDF (Binomial b) Integer Source # 
Instance details

Defined in Data.Random.Distribution.Binomial

PDF (Poisson b) Integer => PDF (Poisson b) Double Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

PDF (Poisson b) Integer => PDF (Poisson b) Float Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

(Real b, Distribution (Poisson b) Word64) => PDF (Poisson b) Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

(Real b, Distribution (Poisson b) Word32) => PDF (Poisson b) Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

(Real b, Distribution (Poisson b) Word16) => PDF (Poisson b) Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

(Real b, Distribution (Poisson b) Word8) => PDF (Poisson b) Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

(Real b, Distribution (Poisson b) Word) => PDF (Poisson b) Word Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

(Real b, Distribution (Poisson b) Int64) => PDF (Poisson b) Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

(Real b, Distribution (Poisson b) Int32) => PDF (Poisson b) Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

(Real b, Distribution (Poisson b) Int16) => PDF (Poisson b) Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

(Real b, Distribution (Poisson b) Int8) => PDF (Poisson b) Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

(Real b, Distribution (Poisson b) Int) => PDF (Poisson b) Int Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Methods

pdf :: Poisson b Int -> Int -> Double Source #

logPdf :: Poisson b Int -> Int -> Double Source #

(Real b, Distribution (Poisson b) Integer) => PDF (Poisson b) Integer Source # 
Instance details

Defined in Data.Random.Distribution.Poisson

Sampling random variables

class Sampleable d m t where Source #

A typeclass allowing Distributions and RVars to be sampled. Both may also be sampled via runRVar or runRVarT, but I find it psychologically pleasing to be able to sample both using this function, as they are two separate abstractions for one base concept: a random variable.

Methods

sampleFrom :: StatefulGen g m => g -> d t -> m t Source #

Directly sample from a distribution or random variable, using the given source of entropy.

Instances

Instances details
Distribution d t => Sampleable d m t Source # 
Instance details

Defined in Data.Random.Sample

Methods

sampleFrom :: StatefulGen g m => g -> d t -> m t Source #

Lift m n => Sampleable (RVarT m) n t Source # 
Instance details

Defined in Data.Random.Sample

Methods

sampleFrom :: StatefulGen g n => g -> RVarT m t -> n t Source #

sample :: (Sampleable d m t, StatefulGen g m, MonadReader g m) => d t -> m t Source #

Sample a random variable using the default source of entropy for the monad in which the sampling occurs.

sampleState :: (Distribution d t, RandomGen g, MonadState g m) => d t -> m t Source #

Sample a random variable in a "functional" style. Typical instantiations of s are System.Random.StdGen or System.Random.Mersenne.Pure64.PureMT. sample :: (Distribution d a, StatefulGen g m, MonadReader g m) => d t -> m t sample thing gen = runStateGen gen (stateGen -> sampleFrom stateGen thing)

samplePure :: (Distribution d t, RandomGen g) => d t -> g -> (t, g) Source #

Sample a random variable in a "functional" style. Typical instantiations of g are System.Random.StdGen or System.Random.Mersenne.Pure64.PureMT.

A few very common distributions

data Uniform t Source #

A definition of a uniform distribution over the type t. See also uniform.

Constructors

Uniform !t !t

A uniform distribution defined by a lower and upper range bound. For Integral and Enum types, the range is inclusive. For Fractional types the range includes the lower bound but not the upper.

Instances

Instances details
CDF Uniform Bool Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Bool -> Bool -> Double Source #

CDF Uniform Char Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Char -> Char -> Double Source #

CDF Uniform Double Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform Float Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Float -> Float -> Double Source #

CDF Uniform Int Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Int -> Int -> Double Source #

CDF Uniform Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Int8 -> Int8 -> Double Source #

CDF Uniform Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Int16 -> Int16 -> Double Source #

CDF Uniform Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Int32 -> Int32 -> Double Source #

CDF Uniform Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Int64 -> Int64 -> Double Source #

CDF Uniform Integer Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform Ordering Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform Word Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Word -> Word -> Double Source #

CDF Uniform Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform Word8 -> Word8 -> Double Source #

CDF Uniform Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF Uniform () Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform () -> () -> Double Source #

Distribution Uniform Bool Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Bool -> RVar Bool Source #

rvarT :: forall (n :: Type -> Type). Uniform Bool -> RVarT n Bool Source #

Distribution Uniform Char Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Char -> RVar Char Source #

rvarT :: forall (n :: Type -> Type). Uniform Char -> RVarT n Char Source #

Distribution Uniform Double Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Double -> RVar Double Source #

rvarT :: forall (n :: Type -> Type). Uniform Double -> RVarT n Double Source #

Distribution Uniform Float Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Float -> RVar Float Source #

rvarT :: forall (n :: Type -> Type). Uniform Float -> RVarT n Float Source #

Distribution Uniform Int Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Int -> RVar Int Source #

rvarT :: forall (n :: Type -> Type). Uniform Int -> RVarT n Int Source #

Distribution Uniform Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Int8 -> RVar Int8 Source #

rvarT :: forall (n :: Type -> Type). Uniform Int8 -> RVarT n Int8 Source #

Distribution Uniform Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Int16 -> RVar Int16 Source #

rvarT :: forall (n :: Type -> Type). Uniform Int16 -> RVarT n Int16 Source #

Distribution Uniform Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Int32 -> RVar Int32 Source #

rvarT :: forall (n :: Type -> Type). Uniform Int32 -> RVarT n Int32 Source #

Distribution Uniform Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Int64 -> RVar Int64 Source #

rvarT :: forall (n :: Type -> Type). Uniform Int64 -> RVarT n Int64 Source #

Distribution Uniform Integer Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution Uniform Ordering Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution Uniform Word Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Word -> RVar Word Source #

rvarT :: forall (n :: Type -> Type). Uniform Word -> RVarT n Word Source #

Distribution Uniform Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Word8 -> RVar Word8 Source #

rvarT :: forall (n :: Type -> Type). Uniform Word8 -> RVarT n Word8 Source #

Distribution Uniform Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Word16 -> RVar Word16 Source #

rvarT :: forall (n :: Type -> Type). Uniform Word16 -> RVarT n Word16 Source #

Distribution Uniform Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Word32 -> RVar Word32 Source #

rvarT :: forall (n :: Type -> Type). Uniform Word32 -> RVarT n Word32 Source #

Distribution Uniform Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform Word64 -> RVar Word64 Source #

rvarT :: forall (n :: Type -> Type). Uniform Word64 -> RVarT n Word64 Source #

Distribution Uniform () Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform () -> RVar () Source #

rvarT :: forall (n :: Type -> Type). Uniform () -> RVarT n () Source #

HasResolution r => CDF Uniform (Fixed r) Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: Uniform (Fixed r) -> Fixed r -> Double Source #

HasResolution r => Distribution Uniform (Fixed r) Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: Uniform (Fixed r) -> RVar (Fixed r) Source #

rvarT :: forall (n :: Type -> Type). Uniform (Fixed r) -> RVarT n (Fixed r) Source #

uniform :: Distribution Uniform a => a -> a -> RVar a Source #

uniformT :: Distribution Uniform a => a -> a -> RVarT m a Source #

data StdUniform t Source #

A name for the "standard" uniform distribution over the type t, if one exists. See also stdUniform.

For Integral and Enum types that are also Bounded, this is the uniform distribution over the full range of the type. For un-Bounded Integral types this is not defined. For Fractional types this is a random variable in the range [0,1) (that is, 0 to 1 including 0 but not including 1).

Constructors

StdUniform 

Instances

Instances details
CDF StdUniform Bool Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Char Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Double Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Float Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Int Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: StdUniform Int -> Int -> Double Source #

CDF StdUniform Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Ordering Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Word Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

CDF StdUniform () Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: StdUniform () -> () -> Double Source #

PDF StdUniform Double Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

PDF StdUniform Float Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Bool Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform Bool -> RVar Bool Source #

rvarT :: forall (n :: Type -> Type). StdUniform Bool -> RVarT n Bool Source #

Distribution StdUniform Char Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform Char -> RVar Char Source #

rvarT :: forall (n :: Type -> Type). StdUniform Char -> RVarT n Char Source #

Distribution StdUniform Double Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Float Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Int Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform Int -> RVar Int Source #

rvarT :: forall (n :: Type -> Type). StdUniform Int -> RVarT n Int Source #

Distribution StdUniform Int8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform Int8 -> RVar Int8 Source #

rvarT :: forall (n :: Type -> Type). StdUniform Int8 -> RVarT n Int8 Source #

Distribution StdUniform Int16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Int32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Int64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Ordering Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Word Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform Word -> RVar Word Source #

rvarT :: forall (n :: Type -> Type). StdUniform Word -> RVarT n Word Source #

Distribution StdUniform Word8 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Word16 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Word32 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform Word64 Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Distribution StdUniform () Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform () -> RVar () Source #

rvarT :: forall (n :: Type -> Type). StdUniform () -> RVarT n () Source #

HasResolution r => CDF StdUniform (Fixed r) Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

cdf :: StdUniform (Fixed r) -> Fixed r -> Double Source #

HasResolution r => Distribution StdUniform (Fixed r) Source # 
Instance details

Defined in Data.Random.Distribution.Uniform

Methods

rvar :: StdUniform (Fixed r) -> RVar (Fixed r) Source #

rvarT :: forall (n :: Type -> Type). StdUniform (Fixed r) -> RVarT n (Fixed r) Source #

stdUniform :: Distribution StdUniform a => RVar a Source #

Get a "standard" uniformly distributed variable. For integral types, this means uniformly distributed over the full range of the type (there is no support for Integer). For fractional types, this means uniformly distributed on the interval [0,1).

stdUniformT :: Distribution StdUniform a => RVarT m a Source #

Get a "standard" uniformly distributed process. For integral types, this means uniformly distributed over the full range of the type (there is no support for Integer). For fractional types, this means uniformly distributed on the interval [0,1).

data Normal a Source #

A specification of a normal distribution over the type a.

Constructors

StdNormal

The "standard" normal distribution - mean 0, stddev 1

Normal a a

Normal m s is a normal distribution with mean m and stddev sd.

Instances

Instances details
(Real a, Distribution Normal a) => CDF Normal a Source # 
Instance details

Defined in Data.Random.Distribution.Normal

Methods

cdf :: Normal a -> a -> Double Source #

(Real a, Floating a, Distribution Normal a) => PDF Normal a Source # 
Instance details

Defined in Data.Random.Distribution.Normal

Methods

pdf :: Normal a -> a -> Double Source #

logPdf :: Normal a -> a -> Double Source #

Distribution Normal Double Source # 
Instance details

Defined in Data.Random.Distribution.Normal

Methods

rvar :: Normal Double -> RVar Double Source #

rvarT :: forall (n :: Type -> Type). Normal Double -> RVarT n Double Source #

Distribution Normal Float Source # 
Instance details

Defined in Data.Random.Distribution.Normal

Methods

rvar :: Normal Float -> RVar Float Source #

rvarT :: forall (n :: Type -> Type). Normal Float -> RVarT n Float Source #

normal :: Distribution Normal a => a -> a -> RVar a Source #

normal m s is a random variable with distribution Normal m s.

stdNormal :: Distribution Normal a => RVar a Source #

stdNormal is a normal variable with distribution StdNormal.

normalT :: Distribution Normal a => a -> a -> RVarT m a Source #

normalT m s is a random process with distribution Normal m s.

stdNormalT :: Distribution Normal a => RVarT m a Source #

stdNormalT is a normal process with distribution StdNormal.

data Gamma a Source #

Constructors

Gamma a a 

Instances

Instances details
(Real a, Distribution Gamma a) => CDF Gamma a Source # 
Instance details

Defined in Data.Random.Distribution.Gamma

Methods

cdf :: Gamma a -> a -> Double Source #

(Floating a, Ord a, Distribution Normal a, Distribution StdUniform a) => Distribution Gamma a Source # 
Instance details

Defined in Data.Random.Distribution.Gamma

Methods

rvar :: Gamma a -> RVar a Source #

rvarT :: forall (n :: Type -> Type). Gamma a -> RVarT n a Source #

gamma :: Distribution Gamma a => a -> a -> RVar a Source #

gammaT :: Distribution Gamma a => a -> a -> RVarT m a Source #

Entropy Sources

class Monad m => StatefulGen g (m :: Type -> Type) #

StatefulGen is an interface to monadic pseudo-random number generators.

Since: random-1.2.0

Instances

Instances details
StatefulGen RGen (RVarT m) 
Instance details

Defined in Data.RVar

(RandomGen g, MonadIO m) => StatefulGen (AtomicGenM g) m 
Instance details

Defined in System.Random.Stateful

(RandomGen g, MonadIO m) => StatefulGen (IOGenM g) m 
Instance details

Defined in System.Random.Stateful

RandomGen g => StatefulGen (TGenM g) STM

Since: random-1.2.1

Instance details

Defined in System.Random.Stateful

(RandomGen g, MonadState g m) => StatefulGen (StateGenM g) m 
Instance details

Defined in System.Random.Internal

(Monad m, RandomGen g) => StatefulGen (RandGen g) (RandT g m)

Since: MonadRandom-0.5.3

Instance details

Defined in Control.Monad.Trans.Random.Strict

(Monad m, RandomGen g) => StatefulGen (RandGen g) (RandT g m)

Since: MonadRandom-0.5.3

Instance details

Defined in Control.Monad.Trans.Random.Lazy

RandomGen g => StatefulGen (STGenM g s) (ST s) 
Instance details

Defined in System.Random.Stateful

class RandomGen g #

RandomGen is an interface to pure pseudo-random number generators.

StdGen is the standard RandomGen instance provided by this library.

Since: random-1.0.0

Minimal complete definition

split, (genWord32 | genWord64 | next, genRange)

Instances

Instances details
RandomGen StdGen 
Instance details

Defined in System.Random.Internal

RandomGen SMGen 
Instance details

Defined in System.Random.Internal

RandomGen SMGen 
Instance details

Defined in System.Random.Internal

RandomGen g => RandomGen (AtomicGen g) 
Instance details

Defined in System.Random.Stateful

RandomGen g => RandomGen (IOGen g) 
Instance details

Defined in System.Random.Stateful

Methods

next :: IOGen g -> (Int, IOGen g) #

genWord8 :: IOGen g -> (Word8, IOGen g) #

genWord16 :: IOGen g -> (Word16, IOGen g) #

genWord32 :: IOGen g -> (Word32, IOGen g) #

genWord64 :: IOGen g -> (Word64, IOGen g) #

genWord32R :: Word32 -> IOGen g -> (Word32, IOGen g) #

genWord64R :: Word64 -> IOGen g -> (Word64, IOGen g) #

genShortByteString :: Int -> IOGen g -> (ShortByteString, IOGen g) #

genRange :: IOGen g -> (Int, Int) #

split :: IOGen g -> (IOGen g, IOGen g) #

RandomGen g => RandomGen (STGen g) 
Instance details

Defined in System.Random.Stateful

Methods

next :: STGen g -> (Int, STGen g) #

genWord8 :: STGen g -> (Word8, STGen g) #

genWord16 :: STGen g -> (Word16, STGen g) #

genWord32 :: STGen g -> (Word32, STGen g) #

genWord64 :: STGen g -> (Word64, STGen g) #

genWord32R :: Word32 -> STGen g -> (Word32, STGen g) #

genWord64R :: Word64 -> STGen g -> (Word64, STGen g) #

genShortByteString :: Int -> STGen g -> (ShortByteString, STGen g) #

genRange :: STGen g -> (Int, Int) #

split :: STGen g -> (STGen g, STGen g) #

RandomGen g => RandomGen (TGen g) 
Instance details

Defined in System.Random.Stateful

Methods

next :: TGen g -> (Int, TGen g) #

genWord8 :: TGen g -> (Word8, TGen g) #

genWord16 :: TGen g -> (Word16, TGen g) #

genWord32 :: TGen g -> (Word32, TGen g) #

genWord64 :: TGen g -> (Word64, TGen g) #

genWord32R :: Word32 -> TGen g -> (Word32, TGen g) #

genWord64R :: Word64 -> TGen g -> (Word64, TGen g) #

genShortByteString :: Int -> TGen g -> (ShortByteString, TGen g) #

genRange :: TGen g -> (Int, Int) #

split :: TGen g -> (TGen g, TGen g) #

RandomGen g => RandomGen (StateGen g) 
Instance details

Defined in System.Random.Internal

Useful list-based operations

randomElement :: [a] -> RVar a Source #

A random variable returning an arbitrary element of the given list. Every element has equal probability of being chosen. Because it is a pure RVar it has no memory - that is, it "draws with replacement."

shuffle :: [a] -> RVar [a] Source #

A random variable that returns the given list in an arbitrary shuffled order. Every ordering of the list has equal probability.

shuffleN :: Int -> [a] -> RVar [a] Source #

A random variable that shuffles a list of a known length (or a list prefix of the specified length). Useful for shuffling large lists when the length is known in advance. Avoids needing to traverse the list to discover its length. Each ordering has equal probability.

shuffleNofM :: Int -> Int -> [a] -> RVar [a] Source #

A random variable that selects N arbitrary elements of a list of known length M.