-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Random number generation
--   
--   Random number generation based on modeling random variables in two
--   complementary ways: first, by the parameters of standard mathematical
--   distributions and, second, by an abstract type (RVar) which can
--   be composed and manipulated monadically and sampled in either monadic
--   or "pure" styles.
--   
--   The primary purpose of this library is to support defining and
--   sampling a wide variety of high quality random variables. Quality is
--   prioritized over speed, but performance is an important goal too.
--   
--   In my testing, I have found it capable of speed comparable to other
--   Haskell libraries, but still a fair bit slower than straight C
--   implementations of the same algorithms.
@package random-fu
@version 0.3.0.1

module Data.Random.Internal.Find
findMax :: (Fractional a, Ord a) => (a -> Bool) -> a

-- | Given an upward-closed predicate on an ordered Fractional type, find
--   the smallest value satisfying the predicate.
findMin :: (Fractional a, Ord a) => (a -> Bool) -> a

-- | Given an upward-closed predicate on an ordered Fractional type, find
--   the smallest value satisfying the predicate. Starts at the specified
--   point with the specified stepsize, performs an exponential search out
--   from there until it finds an interval bracketing the change-point of
--   the predicate, and then performs a bisection search to isolate the
--   change point. Note that infinitely-divisible domains such as
--   Rational cannot be searched by this function because it does
--   not terminate until it reaches a point where further subdivision of
--   the interval has no effect.
findMinFrom :: (Fractional a, Ord a) => a -> a -> (a -> Bool) -> a

module Data.Random.Internal.Fixed
resolutionOf :: HasResolution r => f r -> Integer
resolutionOf2 :: HasResolution r => f (g r) -> Integer

-- | The Fixed type doesn't expose its constructors, but I need a
--   way to convert them to and from their raw representation in order to
--   sample them. As long as Fixed is a newtype wrapping
--   Integer, mkFixed and unMkFixed as defined here
--   will work. Both are implemented using unsafeCoerce.
mkFixed :: Integer -> Fixed r
unMkFixed :: Fixed r -> Integer

module Data.Random.Lift

-- | A class for "liftable" data structures. Conceptually an extension of
--   MonadTrans to allow deep lifting, but lifting need not be done
--   between monads only. Eg lifting between Applicatives is
--   allowed.
--   
--   For instances where m and n have
--   return/pure defined, these instances must satisfy
--   lift (return x) == return x.
--   
--   This form of lift has an extremely general type and is used
--   primarily to support sample. Its excessive generality is the
--   main reason it's not exported from Data.Random. RVarT
--   is, however, an instance of MonadTrans, which in most cases is
--   the preferred way to do the lifting.
class Lift (m :: Type -> Type) (n :: Type -> Type)
lift :: Lift m n => m a -> n a
instance Control.Monad.Trans.Class.MonadTrans t => Data.Random.Lift.Lift GHC.Internal.Data.Functor.Identity.Identity (t GHC.Internal.Data.Functor.Identity.Identity)
instance GHC.Internal.Base.Monad m => Data.Random.Lift.Lift GHC.Internal.Data.Functor.Identity.Identity m
instance Data.Random.Lift.Lift (Data.RVar.RVarT GHC.Internal.Data.Functor.Identity.Identity) (Data.RVar.RVarT m)
instance (GHC.Internal.Base.Monad m, Control.Monad.Trans.Class.MonadTrans t) => Data.Random.Lift.Lift m (t m)
instance Data.Random.Lift.Lift m m

module Data.Random.RVar

-- | 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
--   
type RVar = RVarT Identity

-- | "Run" an RVar - samples the random variable from the provided
--   source of entropy.
runRVar :: StatefulGen g m => RVar a -> g -> m 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
--   
data RVarT (m :: Type -> Type) a

-- | Like runRVarTWith, but using an implicit lifting (provided by
--   the Lift class)
runRVarT :: forall (n :: Type -> Type) m g a. (Lift n m, StatefulGen g m) => 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.
runRVarTWith :: forall m n g a. StatefulGen g m => (forall t. () => n t -> m t) -> RVarT n a -> g -> m a
data RGen
RGen :: RGen
uniformRVarT :: forall a (m :: Type -> Type). Uniform a => RVarT m a
uniformRangeRVarT :: forall a (m :: Type -> Type). UniformRange a => (a, a) -> RVarT m a

module Data.Random.Distribution

-- | 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.
class Distribution (d :: Type -> Type) t

-- | Return a random variable with this distribution.
rvar :: Distribution d t => d t -> RVar t

-- | 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.
rvarT :: forall (n :: Type -> Type). Distribution d t => d t -> RVarT n t
class Distribution d t => PDF (d :: Type -> Type) t
pdf :: PDF d t => d t -> t -> Double
logPdf :: PDF d t => d t -> t -> Double
class Distribution d t => CDF (d :: Type -> Type) t

-- | 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).
cdf :: CDF d t => d t -> t -> Double

module Data.Random.Distribution.Uniform

-- | A definition of a uniform distribution over the type t. See
--   also uniform.
data Uniform 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.
Uniform :: !t -> !t -> Uniform t
uniform :: Distribution Uniform a => a -> a -> RVar a
uniformT :: forall a (m :: Type -> Type). Distribution Uniform a => a -> a -> RVarT m a

-- | 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).
data StdUniform t
StdUniform :: StdUniform t

-- | 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).
stdUniform :: Distribution StdUniform a => RVar a

-- | 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).
stdUniformT :: forall a (m :: Type -> Type). Distribution StdUniform a => RVarT m a

-- | Like stdUniform but only returns positive values.
stdUniformPos :: (Distribution StdUniform a, Num a, Eq a) => RVar a

-- | Like stdUniform but only returns positive values.
stdUniformPosT :: forall a (m :: Type -> Type). (Distribution StdUniform a, Num a, Eq a) => RVarT m a

-- | Compute a random Integral value between the 2 values provided
--   (inclusive).
integralUniform :: forall a (m :: Type -> Type). UniformRange a => a -> a -> RVarT m a

-- | realFloatUniform a b computes a uniform random value in the
--   range [a,b) for any RealFloat type
realFloatUniform :: forall a (m :: Type -> Type). RealFloat a => a -> a -> RVarT m a

-- | floatUniform a b computes a uniform random Float value
--   in the range [a,b)
floatUniform :: forall (m :: Type -> Type). Float -> Float -> RVarT m Float

-- | doubleUniform a b computes a uniform random Double
--   value in the range [a,b)
doubleUniform :: forall (m :: Type -> Type). Double -> Double -> RVarT m Double

-- | fixedUniform a b computes a uniform random Fixed value
--   in the range [a,b), with any desired precision.
fixedUniform :: forall r (m :: Type -> Type). HasResolution r => Fixed r -> Fixed r -> RVarT m (Fixed r)

-- | realFloatUniform a b computes a uniform random value in the
--   range [a,b) for any Enum type
enumUniform :: forall a (m :: Type -> Type). Enum a => a -> a -> RVarT m a

-- | Compute a random value for a Bounded type, between
--   minBound and maxBound (inclusive for Integral or
--   Enum types, in [minBound, maxBound) for
--   Fractional types.)
boundedStdUniform :: (Distribution Uniform a, Bounded a) => RVar a

-- | Compute a random value for a Bounded Enum type, between
--   minBound and maxBound (inclusive)
boundedEnumStdUniform :: forall a (m :: Type -> Type). (Enum a, Bounded a) => RVarT m a

-- | Compute a uniform random value in the range [0,1) for any
--   RealFloat type
realFloatStdUniform :: forall a (m :: Type -> Type). RealFloat a => RVarT m a

-- | Compute a uniform random Fixed value in the range [0,1), with
--   any desired precision.
fixedStdUniform :: forall r (m :: Type -> Type). HasResolution r => RVarT m (Fixed r)

-- | Compute a uniform random Float value in the range [0,1)
floatStdUniform :: forall (m :: Type -> Type). RVarT m Float

-- | Compute a uniform random Double value in the range [0,1)
doubleStdUniform :: forall (m :: Type -> Type). RVarT m Double
boundedStdUniformCDF :: (CDF Uniform a, Bounded a) => a -> Double

-- | The CDF of the random variable realFloatStdUniform.
realStdUniformCDF :: Real a => a -> Double

-- | realUniformCDF a b is the CDF of the random variable
--   realFloatUniform a b.
realUniformCDF :: RealFrac a => a -> a -> a -> Double
enumUniformCDF :: (Enum a, Ord a) => a -> a -> a -> Double
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Types.Bool
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Types.Char
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Types.Double
instance Data.Fixed.HasResolution r => Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform (Data.Fixed.Fixed r)
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Types.Float
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Types.Int
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Int.Int16
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Int.Int32
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Int.Int64
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Int.Int8
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Types.Ordering
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform ()
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Types.Word
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Word.Word16
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Word.Word32
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Word.Word64
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Word.Word8
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Types.Bool
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Types.Char
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Types.Double
instance Data.Fixed.HasResolution r => Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform (Data.Fixed.Fixed r)
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Types.Float
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Types.Int
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Internal.Int.Int16
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Internal.Int.Int32
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Internal.Int.Int64
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Internal.Int.Int8
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Num.Integer.Integer
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Types.Ordering
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform ()
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Types.Word
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Internal.Word.Word16
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Internal.Word.Word32
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Internal.Word.Word64
instance Data.Random.Distribution.CDF Data.Random.Distribution.Uniform.Uniform GHC.Internal.Word.Word8
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Types.Bool
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Types.Char
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Types.Double
instance Data.Fixed.HasResolution r => Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform (Data.Fixed.Fixed r)
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Types.Float
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Types.Int
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Int.Int16
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Int.Int32
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Int.Int64
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Int.Int8
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Types.Ordering
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform ()
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Types.Word
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Word.Word16
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Word.Word32
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Word.Word64
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform GHC.Internal.Word.Word8
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Types.Bool
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Types.Char
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Types.Double
instance Data.Fixed.HasResolution r => Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform (Data.Fixed.Fixed r)
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Types.Float
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Types.Int
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Internal.Int.Int16
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Internal.Int.Int32
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Internal.Int.Int64
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Internal.Int.Int8
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Num.Integer.Integer
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Types.Ordering
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform ()
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Types.Word
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Internal.Word.Word16
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Internal.Word.Word32
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Internal.Word.Word64
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform GHC.Internal.Word.Word8
instance Data.Random.Distribution.PDF Data.Random.Distribution.Uniform.StdUniform GHC.Types.Double
instance Data.Random.Distribution.PDF Data.Random.Distribution.Uniform.StdUniform GHC.Types.Float

module Data.Random.List

-- | 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."
randomElement :: [a] -> RVar a
randomElementT :: forall a (m :: Type -> Type). [a] -> RVarT m a

-- | A random variable that returns the given list in an arbitrary shuffled
--   order. Every ordering of the list has equal probability.
shuffle :: [a] -> RVar [a]
shuffleT :: forall a (m :: Type -> Type). [a] -> RVarT m [a]

-- | 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.
shuffleN :: Int -> [a] -> RVar [a]
shuffleNT :: forall a (m :: Type -> Type). Int -> [a] -> RVarT m [a]

-- | A random variable that selects N arbitrary elements of a list of known
--   length M.
shuffleNofM :: Int -> Int -> [a] -> RVar [a]
shuffleNofMT :: forall a (m :: Type -> Type). Int -> Int -> [a] -> RVarT m [a]

-- | A generic "ziggurat algorithm" implementation. Fairly rough right now.
--   
--   There is a lot of room for improvement in findBin0 especially.
--   It needs a fair amount of cleanup and elimination of redundant
--   calculation, as well as either a justification for using the simple
--   findMinFrom or a proper root-finding algorithm.
--   
--   It would also be nice to add (preferably by pulling in an external
--   package) support for numerical integration and differentiation, so
--   that tables can be derived from only a PDF (if the end user is willing
--   to take the performance and accuracy hit for the convenience).
module Data.Random.Distribution.Ziggurat

-- | A data structure containing all the data that is needed to implement
--   Marsaglia & Tang's "ziggurat" algorithm for sampling certain kinds
--   of random distributions.
--   
--   The documentation here is probably not sufficient to tell a user
--   exactly how to build one of these from scratch, but it is not really
--   intended to be. There are several helper functions that will build
--   Ziggurats. The pathologically curious may wish to read the
--   runZiggurat source. That is the ultimate specification of the
--   semantics of all these fields.
data Ziggurat (v :: Type -> Type) t
Ziggurat :: !v t -> !v t -> !v t -> !forall (m :: Type -> Type). () => RVarT m (Int, t) -> (forall (m :: Type -> Type). () => RVarT m t) -> !forall (m :: Type -> Type). () => t -> t -> RVarT m t -> !t -> t -> !Bool -> Ziggurat (v :: Type -> Type) t

-- | The X locations of each bin in the distribution. Bin 0 is the
--   infinite one.
--   
--   In the case of bin 0, the value given is sort of magical - x[0] is
--   defined to be V/f(R). It's not actually the location of any bin, but a
--   value computed to make the algorithm more concise and slightly faster
--   by not needing to specially-handle bin 0 quite as often. If you really
--   need to know why it works, see the runZiggurat source or "the
--   literature" - it's a fairly standard setup.
[zTable_xs] :: Ziggurat (v :: Type -> Type) t -> !v t

-- | The ratio of each bin's Y value to the next bin's Y value
[zTable_y_ratios] :: Ziggurat (v :: Type -> Type) t -> !v t

-- | The Y value (zFunc x) of each bin
[zTable_ys] :: Ziggurat (v :: Type -> Type) t -> !v t

-- | An RVar providing a random tuple consisting of:
--   
--   
--   
- a bin index, uniform over [0,c) :: Int (where c is the
--   number of bins in the tables)
--   
- a uniformly distributed fractional value, from -1 to 1 if not
--   mirrored, from 0 to 1 otherwise.
--   
--   
--   This is provided as a single RVar because it can be implemented
--   more efficiently than naively sampling 2 separate values - a single
--   random word (64 bits) can be efficiently converted to a double (using
--   52 bits) and a bin number (using up to 12 bits), for example.
[zGetIU] :: Ziggurat (v :: Type -> Type) t -> !forall (m :: Type -> Type). () => RVarT m (Int, t)

-- | The distribution for the final "virtual" bin (the ziggurat algorithm
--   does not handle distributions that wander off to infinity, so another
--   distribution is needed to handle the last "bin" that stretches to
--   infinity)
[zTailDist] :: Ziggurat (v :: Type -> Type) t -> forall (m :: Type -> Type). () => RVarT m t

-- | A copy of the uniform RVar generator for the base type, so that
--   Distribution Uniform t is not needed when sampling from a
--   Ziggurat (makes it a bit more self-contained).
[zUniform] :: Ziggurat (v :: Type -> Type) t -> !forall (m :: Type -> Type). () => t -> t -> RVarT m t

-- | The (one-sided antitone) PDF, not necessarily normalized
[zFunc] :: Ziggurat (v :: Type -> Type) t -> !t -> t

-- | A flag indicating whether the distribution should be mirrored about
--   the origin (the ziggurat algorithm in its native form only samples
--   from one-sided distributions. By mirroring, we can extend it to
--   symmetric distributions such as the normal distribution)
[zMirror] :: Ziggurat (v :: Type -> Type) t -> !Bool

-- | Build a lazy recursive ziggurat. Uses a lazily-constructed ziggurat as
--   its tail distribution (with another as its tail, ad nauseam).
--   
--   Arguments:
--   
--   
--   
- flag indicating whether to mirror the distribution
--   
- the (one-sided antitone) PDF, not necessarily normalized
--   
- the inverse of the PDF
--   
- the integral of the PDF (definite, from 0)
--   
- the estimated volume under the PDF (from 0 to +infinity)
--   
- the chunk size (number of bins in each layer). 64 seems to perform
--   well in practice.
--   
- an RVar providing the zGetIU random tuple
--   
mkZigguratRec :: forall t (v :: Type -> Type). (RealFloat t, Vector v t, Distribution Uniform t) => Bool -> (t -> t) -> (t -> t) -> (t -> t) -> t -> Int -> (forall (m :: Type -> Type). () => RVarT m (Int, t)) -> Ziggurat v t

-- | Build the tables to implement the "ziggurat algorithm" devised by
--   Marsaglia & Tang, attempting to automatically compute the R and V
--   values.
--   
--   Arguments are the same as for mkZigguratRec, with an additional
--   argument for the tail distribution as a function of the selected R
--   value.
mkZiggurat :: forall t (v :: Type -> Type). (RealFloat t, Vector v t, Distribution Uniform t) => Bool -> (t -> t) -> (t -> t) -> (t -> t) -> t -> Int -> (forall (m :: Type -> Type). () => RVarT m (Int, t)) -> (forall (m :: Type -> Type). () => t -> RVarT m t) -> Ziggurat v t

-- | Build the tables to implement the "ziggurat algorithm" devised by
--   Marsaglia & Tang, attempting to automatically compute the R and V
--   values.
--   
--   Arguments:
--   
--   
--   
- flag indicating whether to mirror the distribution
--   
- the (one-sided antitone) PDF, not necessarily normalized
--   
- the inverse of the PDF
--   
- the number of bins
--   
- R, the x value of the first bin
--   
- V, the volume of each bin
--   
- an RVar providing the zGetIU random tuple
--   
- an RVar sampling from the tail (the region where x > R)
--   
mkZiggurat_ :: forall t (v :: Type -> Type). (RealFloat t, Vector v t, Distribution Uniform t) => Bool -> (t -> t) -> (t -> t) -> Int -> t -> t -> (forall (m :: Type -> Type). () => RVarT m (Int, t)) -> (forall (m :: Type -> Type). () => RVarT m t) -> Ziggurat v t

-- | I suspect this isn't completely right, but it works well so far.
--   Search the distribution for an appropriate R and V.
--   
--   Arguments:
--   
--   
--   
- Number of bins
--   
- target function (one-sided antitone PDF, not necessarily
--   normalized)
--   
- function inverse
--   
- function definite integral (from 0 to _)
--   
- estimate of total volume under function (integral from 0 to
--   infinity)
--   
--   
--   Result: (R,V)
findBin0 :: RealFloat b => Int -> (b -> b) -> (b -> b) -> (b -> b) -> b -> (b, b)

-- | Sample from the distribution encoded in a Ziggurat data
--   structure.
runZiggurat :: forall a (v :: Type -> Type) (m :: Type -> Type). (Num a, Ord a, Vector v a) => Ziggurat v a -> RVarT m a
instance (GHC.Internal.Num.Num t, GHC.Classes.Ord t, Data.Vector.Generic.Base.Vector v t) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Ziggurat.Ziggurat v) t

module Data.Random.Distribution.Weibull
data Weibull a
Weibull :: !a -> !a -> Weibull a
[weibullLambda] :: Weibull a -> !a
[weibullK] :: Weibull a -> !a
instance (GHC.Internal.Real.Real a, Data.Random.Distribution.Distribution Data.Random.Distribution.Weibull.Weibull a) => Data.Random.Distribution.CDF Data.Random.Distribution.Weibull.Weibull a
instance (GHC.Internal.Float.Floating a, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform a) => Data.Random.Distribution.Distribution Data.Random.Distribution.Weibull.Weibull a
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Random.Distribution.Weibull.Weibull a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Data.Random.Distribution.Weibull.Weibull a)

module Data.Random.Distribution.Triangular

-- | A description of a triangular distribution - a distribution whose PDF
--   is a triangle ramping up from a lower bound to a specified midpoint
--   and back down to the upper bound. This is a very simple distribution
--   that does not generally occur naturally but is used sometimes as an
--   estimate of a true distribution when only the range of the values and
--   an approximate mode of the true distribution are known.
data Triangular a
Triangular :: a -> a -> a -> Triangular a

-- | The lower bound of the triangle in the PDF (the smallest number the
--   distribution can generate)
[triLower] :: Triangular a -> a

-- | The midpoint of the triangle (also the mode of the distribution)
[triMid] :: Triangular a -> a

-- | The upper bound of the triangle (and the largest number the
--   distribution can generate)
[triUpper] :: Triangular a -> a

-- | Compute a triangular distribution for a Floating type.
floatingTriangular :: forall a (m :: Type -> Type). (Floating a, Ord a, Distribution StdUniform a) => a -> a -> a -> RVarT m a

-- | triangularCDF a b c is the CDF of realFloatTriangular a b
--   c.
triangularCDF :: RealFrac a => a -> a -> a -> a -> Double
instance (GHC.Internal.Real.RealFrac a, Data.Random.Distribution.Distribution Data.Random.Distribution.Triangular.Triangular a) => Data.Random.Distribution.CDF Data.Random.Distribution.Triangular.Triangular a
instance (GHC.Internal.Float.RealFloat a, GHC.Classes.Ord a, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform a) => Data.Random.Distribution.Distribution Data.Random.Distribution.Triangular.Triangular a
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Random.Distribution.Triangular.Triangular a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Data.Random.Distribution.Triangular.Triangular a)

module Data.Random.Distribution.StretchedExponential
newtype StretchedExponential a
StretchedExp :: (a, a) -> StretchedExponential a
floatingStretchedExponential :: forall a (m :: Type -> Type). (Floating a, Distribution StdUniform a) => a -> a -> RVarT m a
floatingStretchedExponentialCDF :: Real a => a -> a -> a -> Double
stretchedExponential :: Distribution StretchedExponential a => a -> a -> RVar a
stretchedExponentialT :: forall a (m :: Type -> Type). Distribution StretchedExponential a => a -> a -> RVarT m a
instance (GHC.Internal.Real.Real a, Data.Random.Distribution.Distribution Data.Random.Distribution.StretchedExponential.StretchedExponential a) => Data.Random.Distribution.CDF Data.Random.Distribution.StretchedExponential.StretchedExponential a
instance (GHC.Internal.Float.Floating a, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform a) => Data.Random.Distribution.Distribution Data.Random.Distribution.StretchedExponential.StretchedExponential a

module Data.Random.Distribution.Simplex

-- | Uniform distribution over a standard simplex.
newtype StdSimplex as

-- | StdSimplex k constructs a standard simplex of dimension
--   k (standard k-simplex). An element of the simplex
--   represents a vector variable as = (a_0, a_1, ..., a_k). The
--   elements of as are more than or equal to 0 and
--   sum as is always equal to 1.
StdSimplex :: Int -> StdSimplex as

-- | stdSimplex k returns a random variable being uniformly
--   distributed over a standard simplex of dimension k.
stdSimplex :: Distribution StdSimplex [a] => Int -> RVar [a]
stdSimplexT :: forall a (m :: Type -> Type). Distribution StdSimplex [a] => Int -> RVarT m [a]

-- | An algorithm proposed by Rubinstein & Melamed (1998). See,
--   e.g., S. Onn, I. Weissman. Generating uniform random vectors
--   over a simplex with implications to the volume of a certain polytope
--   and to multivariate extremes. Ann Oper Res (2011)
--   189:331-342.
fractionalStdSimplex :: (Ord a, Fractional a, Distribution StdUniform a) => Int -> RVar [a]
instance (GHC.Classes.Ord a, GHC.Internal.Real.Fractional a, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform a) => Data.Random.Distribution.Distribution Data.Random.Distribution.Simplex.StdSimplex [a]
instance GHC.Classes.Eq (Data.Random.Distribution.Simplex.StdSimplex as)
instance GHC.Internal.Show.Show (Data.Random.Distribution.Simplex.StdSimplex as)

module Data.Random.Distribution.Rayleigh
floatingRayleigh :: forall a (m :: Type -> Type). (Floating a, Eq a, Distribution StdUniform a) => a -> RVarT m a

-- | The rayleigh distribution with a specified mode ("sigma") parameter.
--   Its mean will be sigma*sqrt(pi/2) and its variance will be
--   sigma^2*(4-pi)/2
--   
--   (therefore if you want one with a particular mean m,
--   sigma should be m*sqrt(2/pi))
newtype Rayleigh a
Rayleigh :: a -> Rayleigh a
rayleigh :: Distribution Rayleigh a => a -> RVar a
rayleighT :: forall a (m :: Type -> Type). Distribution Rayleigh a => a -> RVarT m a
rayleighCDF :: Real a => a -> a -> Double
instance (GHC.Internal.Real.Real a, Data.Random.Distribution.Distribution Data.Random.Distribution.Rayleigh.Rayleigh a) => Data.Random.Distribution.CDF Data.Random.Distribution.Rayleigh.Rayleigh a
instance (GHC.Internal.Float.RealFloat a, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform a) => Data.Random.Distribution.Distribution Data.Random.Distribution.Rayleigh.Rayleigh a

module Data.Random.Distribution.Normal

-- | A specification of a normal distribution over the type a.
data Normal a

-- | The "standard" normal distribution - mean 0, stddev 1
StdNormal :: Normal a

-- | Normal m s is a normal distribution with mean m and
--   stddev sd.
Normal :: a -> a -> Normal a

-- | normal m s is a random variable with distribution
--   Normal m s.
normal :: Distribution Normal a => a -> a -> RVar a

-- | normalT m s is a random process with distribution
--   Normal m s.
normalT :: forall a (m :: Type -> Type). Distribution Normal a => a -> a -> RVarT m a

-- | stdNormal is a normal variable with distribution
--   StdNormal.
stdNormal :: Distribution Normal a => RVar a

-- | stdNormalT is a normal process with distribution
--   StdNormal.
stdNormalT :: forall a (m :: Type -> Type). Distribution Normal a => RVarT m a

-- | A random variable sampling from the standard normal distribution over
--   the Double type.
doubleStdNormal :: forall (m :: Type -> Type). RVarT m Double

-- | A random variable sampling from the standard normal distribution over
--   the Float type.
floatStdNormal :: forall (m :: Type -> Type). RVarT m Float

-- | A random variable sampling from the standard normal distribution over
--   any RealFloat type (subject to the rest of the constraints - it
--   builds and uses a Ziggurat internally, which requires the
--   Erf class).
--   
--   Because it computes a Ziggurat, it is very expensive to use for
--   just one evaluation, or even for multiple evaluations if not used and
--   reused monomorphically (to enable the ziggurat table to be let-floated
--   out). If you don't know whether your use case fits this description
--   then you're probably better off using a different algorithm, such as
--   boxMullerNormalPair or knuthPolarNormalPair. And of
--   course if you don't need the full generality of this definition then
--   you're much better off using doubleStdNormal or
--   floatStdNormal.
--   
--   As far as I know, this should be safe to use in any monomorphic
--   Distribution Normal instance declaration.
realFloatStdNormal :: forall a (m :: Type -> Type). (RealFloat a, Erf a, Distribution Uniform a) => RVarT m a

-- | Draw from the tail of a normal distribution (the region beyond the
--   provided value)
normalTail :: forall a (m :: Type -> Type). (Distribution StdUniform a, Floating a, Ord a) => a -> RVarT m a

-- | A random variable that produces a pair of independent
--   normally-distributed values.
normalPair :: (Floating a, Distribution StdUniform a) => RVar (a, a)

-- | A random variable that produces a pair of independent
--   normally-distributed values, computed using the Box-Muller method.
--   This algorithm is slightly slower than Knuth's method but using a
--   constant amount of entropy (Knuth's method is a rejection method). It
--   is also slightly more general (Knuth's method require an Ord
--   instance).
boxMullerNormalPair :: (Floating a, Distribution StdUniform a) => RVar (a, a)

-- | A random variable that produces a pair of independent
--   normally-distributed values, computed using Knuth's polar method.
--   Slightly faster than boxMullerNormalPair when it accepts on the
--   first try, but does not always do so.
knuthPolarNormalPair :: (Floating a, Ord a, Distribution Uniform a) => RVar (a, a)
instance (GHC.Internal.Real.Real a, Data.Random.Distribution.Distribution Data.Random.Distribution.Normal.Normal a) => Data.Random.Distribution.CDF Data.Random.Distribution.Normal.Normal a
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Normal.Normal GHC.Types.Double
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Normal.Normal GHC.Types.Float
instance (GHC.Internal.Real.Real a, GHC.Internal.Float.Floating a, Data.Random.Distribution.Distribution Data.Random.Distribution.Normal.Normal a) => Data.Random.Distribution.PDF Data.Random.Distribution.Normal.Normal a

module Data.Random.Distribution.Gamma
data Gamma a
Gamma :: a -> a -> Gamma a
gamma :: Distribution Gamma a => a -> a -> RVar a
gammaT :: forall a (m :: Type -> Type). Distribution Gamma a => a -> a -> RVarT m a
newtype Erlang a b
Erlang :: a -> Erlang a b
erlang :: Distribution (Erlang a) b => a -> RVar b
erlangT :: forall a b (m :: Type -> Type). Distribution (Erlang a) b => a -> RVarT m b

-- | derived from Marsaglia & Tang, "A Simple Method for generating
--   gamma variables", ACM Transactions on Mathematical Software, Vol 26,
--   No 3 (2000), p363-372.
mtGamma :: forall a (m :: Type -> Type). (Floating a, Ord a, Distribution StdUniform a, Distribution Normal a) => a -> a -> RVarT m a
instance (GHC.Internal.Real.Integral a, GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang a) b) => Data.Random.Distribution.CDF (Data.Random.Distribution.Gamma.Erlang a) b
instance (GHC.Internal.Real.Real a, Data.Random.Distribution.Distribution Data.Random.Distribution.Gamma.Gamma a) => Data.Random.Distribution.CDF Data.Random.Distribution.Gamma.Gamma a
instance (GHC.Internal.Real.Integral a, GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Normal.Normal b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang a) b
instance (GHC.Internal.Float.Floating a, GHC.Classes.Ord a, Data.Random.Distribution.Distribution Data.Random.Distribution.Normal.Normal a, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform a) => Data.Random.Distribution.Distribution Data.Random.Distribution.Gamma.Gamma a

module Data.Random.Distribution.Exponential

-- | A definition of the exponential distribution over the type a.
--   
--   Exp mu models an exponential distribution with mean
--   mu. This can alternatively be viewed as an exponential
--   distribution with parameter lambda = 1 / mu.
--   
--   See also exponential.
newtype Exponential a
Exp :: a -> Exponential a
floatingExponential :: forall a (m :: Type -> Type). (Floating a, Distribution StdUniform a) => a -> RVarT m a
floatingExponentialCDF :: Real a => a -> a -> Double

-- | A random variable which samples from the exponential distribution.
--   
--   exponential mu is an exponential random variable with
--   mean mu. This can alternatively be viewed as an exponential
--   random variable with parameter lambda = 1 / mu.
exponential :: Distribution Exponential a => a -> RVar a

-- | A random variable transformer which samples from the exponential
--   distribution.
--   
--   exponentialT mu is an exponential random variable with
--   mean mu. This can alternatively be viewed as an exponential
--   random variable with parameter lambda = 1 / mu.
exponentialT :: forall a (m :: Type -> Type). Distribution Exponential a => a -> RVarT m a
instance (GHC.Internal.Real.Real a, Data.Random.Distribution.Distribution Data.Random.Distribution.Exponential.Exponential a) => Data.Random.Distribution.CDF Data.Random.Distribution.Exponential.Exponential a
instance (GHC.Internal.Float.Floating a, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform a) => Data.Random.Distribution.Distribution Data.Random.Distribution.Exponential.Exponential a

module Data.Random.Distribution.Dirichlet
fractionalDirichlet :: forall a (m :: Type -> Type). (Fractional a, Distribution Gamma a) => [a] -> RVarT m [a]
dirichlet :: Distribution Dirichlet [a] => [a] -> RVar [a]
dirichletT :: forall a (m :: Type -> Type). Distribution Dirichlet [a] => [a] -> RVarT m [a]
newtype Dirichlet a
Dirichlet :: a -> Dirichlet a
instance (GHC.Internal.Real.Fractional a, Data.Random.Distribution.Distribution Data.Random.Distribution.Gamma.Gamma a) => Data.Random.Distribution.Distribution Data.Random.Distribution.Dirichlet.Dirichlet [a]
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Random.Distribution.Dirichlet.Dirichlet a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Data.Random.Distribution.Dirichlet.Dirichlet a)

module Data.Random.Distribution.ChiSquare
chiSquare :: Distribution ChiSquare t => Integer -> RVar t
chiSquareT :: forall t (m :: Type -> Type). Distribution ChiSquare t => Integer -> RVarT m t
newtype ChiSquare b
ChiSquare :: Integer -> ChiSquare b
instance (GHC.Internal.Real.Real t, Data.Random.Distribution.Distribution Data.Random.Distribution.ChiSquare.ChiSquare t) => Data.Random.Distribution.CDF Data.Random.Distribution.ChiSquare.ChiSquare t
instance (GHC.Internal.Real.Fractional t, Data.Random.Distribution.Distribution Data.Random.Distribution.Gamma.Gamma t) => Data.Random.Distribution.Distribution Data.Random.Distribution.ChiSquare.ChiSquare t

module Data.Random.Distribution.T
t :: Distribution T a => Integer -> RVar a
tT :: forall a (m :: Type -> Type). Distribution T a => Integer -> RVarT m a
newtype T a
T :: Integer -> T a
instance (GHC.Internal.Real.Real a, Data.Random.Distribution.Distribution Data.Random.Distribution.T.T a) => Data.Random.Distribution.CDF Data.Random.Distribution.T.T a
instance (GHC.Internal.Float.Floating a, Data.Random.Distribution.Distribution Data.Random.Distribution.Normal.Normal a, Data.Random.Distribution.Distribution Data.Random.Distribution.ChiSquare.ChiSquare a) => Data.Random.Distribution.Distribution Data.Random.Distribution.T.T a
instance GHC.Classes.Eq (Data.Random.Distribution.T.T a)
instance GHC.Classes.Ord (Data.Random.Distribution.T.T a)
instance GHC.Internal.Show.Show (Data.Random.Distribution.T.T a)

module Data.Random.Distribution.Categorical

-- | Categorical distribution; a list of events with corresponding
--   probabilities. The sum of the probabilities must be 1, and no event
--   should have a zero or negative probability (at least, at time of
--   sampling; very clever users can do what they want with the numbers
--   before sampling, just make sure that if you're one of those clever
--   ones, you at least eliminate negative weights before sampling).
data Categorical p a

-- | Construct a Categorical random variable from a list of
--   probabilities and categories, where the probabilities all sum to 1.
categorical :: (Num p, Distribution (Categorical p) a) => [(p, a)] -> RVar a

-- | Construct a Categorical random process from a list of
--   probabilities and categories, where the probabilities all sum to 1.
categoricalT :: forall p a (m :: Type -> Type). (Num p, Distribution (Categorical p) a) => [(p, a)] -> RVarT m a

-- | Construct a Categorical random variable from a list of weights
--   and categories. The weights do not have to sum to 1.
weightedCategorical :: (Fractional p, Eq p, Distribution (Categorical p) a) => [(p, a)] -> RVar a

-- | Construct a Categorical random process from a list of weights
--   and categories. The weights do not have to sum to 1.
weightedCategoricalT :: forall p a (m :: Type -> Type). (Fractional p, Eq p, Distribution (Categorical p) a) => [(p, a)] -> RVarT m a

-- | Construct a Categorical distribution from a list of weighted
--   categories.
fromList :: Num p => [(p, a)] -> Categorical p a
toList :: Num p => Categorical p a -> [(p, a)]
totalWeight :: Num p => Categorical p a -> p
numEvents :: Categorical p a -> Int

-- | Construct a Categorical distribution from a list of weighted
--   categories, where the weights do not necessarily sum to 1.
fromWeightedList :: (Fractional p, Eq p) => [(p, a)] -> Categorical p a

-- | Construct a Categorical distribution from a list of observed
--   outcomes. Equivalent events will be grouped and counted, and the
--   probabilities of each event in the returned distribution will be
--   proportional to the number of occurrences of that event.
fromObservations :: (Fractional p, Eq p, Ord a) => [a] -> Categorical p a

-- | Like fmap, but for the probabilities of a categorical
--   distribution.
mapCategoricalPs :: (Num p, Num q) => (p -> q) -> Categorical p e -> Categorical q e

-- | Adjust all the weights of a categorical distribution so that they sum
--   to unity and remove all events whose probability is zero.
normalizeCategoricalPs :: (Fractional p, Eq p) => Categorical p e -> Categorical p e

-- | Simplify a categorical distribution by combining equivalent events
--   (the new event will have a probability equal to the sum of all the
--   originals).
collectEvents :: (Ord e, Num p, Ord p) => Categorical p e -> Categorical p e

-- | Simplify a categorical distribution by combining equivalent events
--   (the new event will have a weight equal to the sum of all the
--   originals). The comparator function is used to identify events to
--   combine. Once chosen, the events and their weights are combined by the
--   provided probability and event aggregation function.
collectEventsBy :: Num p => (e -> e -> Ordering) -> ([(p, e)] -> (p, e)) -> Categorical p e -> Categorical p e
instance GHC.Internal.Real.Fractional p => GHC.Internal.Base.Applicative (Data.Random.Distribution.Categorical.Categorical p)
instance (GHC.Internal.Real.Fractional p, GHC.Classes.Ord p, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.Uniform p) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Categorical.Categorical p) a
instance (GHC.Classes.Eq p, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Random.Distribution.Categorical.Categorical p a)
instance GHC.Internal.Data.Foldable.Foldable (Data.Random.Distribution.Categorical.Categorical p)
instance GHC.Internal.Base.Functor (Data.Random.Distribution.Categorical.Categorical p)
instance GHC.Internal.Real.Fractional p => GHC.Internal.Base.Monad (Data.Random.Distribution.Categorical.Categorical p)
instance (GHC.Internal.Num.Num p, GHC.Internal.Read.Read p, GHC.Internal.Read.Read a) => GHC.Internal.Read.Read (Data.Random.Distribution.Categorical.Categorical p a)
instance (GHC.Internal.Num.Num p, GHC.Internal.Show.Show p, GHC.Internal.Show.Show a) => GHC.Internal.Show.Show (Data.Random.Distribution.Categorical.Categorical p a)
instance GHC.Internal.Data.Traversable.Traversable (Data.Random.Distribution.Categorical.Categorical p)

module Data.Random.Distribution.Beta
fractionalBeta :: forall a (m :: Type -> Type). (Fractional a, Eq a, Distribution Gamma a, Distribution StdUniform a) => a -> a -> RVarT m a
beta :: Distribution Beta a => a -> a -> RVar a
betaT :: forall a (m :: Type -> Type). Distribution Beta a => a -> a -> RVarT m a
data Beta a
Beta :: a -> a -> Beta a
logBetaPdf :: Double -> Double -> Double -> Double
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta GHC.Types.Double
instance Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta GHC.Types.Float
instance Data.Random.Distribution.PDF Data.Random.Distribution.Beta.Beta GHC.Types.Double
instance Data.Random.Distribution.PDF Data.Random.Distribution.Beta.Beta GHC.Types.Float

module Data.Random.Distribution.Binomial
integralBinomial :: forall a b (m :: Type -> Type). (Integral a, Floating b, Ord b, Distribution Beta b, Distribution StdUniform b) => a -> b -> RVarT m a
integralBinomialCDF :: (Integral a, Real b) => a -> b -> a -> Double

-- | The probability of getting exactly k successes in n trials is given by
--   the probability mass function:
--   
--   <math>
--   
--   Note that in integralBinomialPDF the parameters of the mass
--   function are given first and the range of the random variable
--   distributed according to the binomial distribution is given last. That
--   is, <math> is calculated by integralBinomialPDF 4 0.5
--   2.
integralBinomialPDF :: (Integral a, Real b) => a -> b -> a -> Double

-- | We use the method given in "Fast and accurate computation of binomial
--   probabilities, Loader, C",
--   http://octave.1599824.n4.nabble.com/attachment/3829107/0/loader2000Fast.pdf
integralBinomialLogPdf :: (Integral a, Real b) => a -> b -> a -> Double
floatingBinomial :: (RealFrac a, Distribution (Binomial b) Integer) => a -> b -> RVar a
floatingBinomialCDF :: (CDF (Binomial b) Integer, RealFrac a) => a -> b -> a -> Double
floatingBinomialPDF :: (PDF (Binomial b) Integer, RealFrac a) => a -> b -> a -> Double
floatingBinomialLogPDF :: (PDF (Binomial b) Integer, RealFrac a) => a -> b -> a -> Double
binomial :: Distribution (Binomial b) a => a -> b -> RVar a
binomialT :: forall b a (m :: Type -> Type). Distribution (Binomial b) a => a -> b -> RVarT m a
data Binomial b a
Binomial :: a -> b -> Binomial b a
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Double
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Float
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Int) => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Int
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int16) => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int16
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int32) => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int32
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int64) => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int64
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int8) => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int8
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer) => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Word) => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Word
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word16) => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word16
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word32) => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word32
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word64) => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word64
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word8) => Data.Random.Distribution.CDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word8
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Double
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Float
instance (GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Int
instance (GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int16
instance (GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int32
instance (GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int64
instance (GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int8
instance (GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer
instance (GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Word
instance (GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word16
instance (GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word32
instance (GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word64
instance (GHC.Internal.Float.Floating b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Beta.Beta b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word8
instance Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Double
instance Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Float
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Int) => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Int
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int16) => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int16
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int32) => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int32
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int64) => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int64
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int8) => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int8
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer) => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Word) => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Word
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word16) => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word16
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word32) => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word32
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word64) => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word64
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word8) => Data.Random.Distribution.PDF (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word8

module Data.Random.Distribution.Poisson
integralPoisson :: forall a b (m :: Type -> Type). (Integral a, RealFloat b, Distribution StdUniform b, Distribution (Erlang a) b, Distribution (Binomial b) a) => b -> RVarT m a
integralPoissonCDF :: (Integral a, Real b) => b -> a -> Double

-- | The probability of getting exactly k successes is given by the
--   probability mass function:
--   
--   <math>
--   
--   Note that in integralPoissonPDF the parameter of the mass
--   function are given first and the range of the random variable
--   distributed according to the Poisson distribution is given last. That
--   is, <math> is calculated by integralPoissonPDF 0.5 2.
integralPoissonPDF :: (Integral a, Real b) => b -> a -> Double
fractionalPoisson :: forall a b (m :: Type -> Type). (Num a, Distribution (Poisson b) Integer) => b -> RVarT m a
fractionalPoissonCDF :: (CDF (Poisson b) Integer, RealFrac a) => b -> a -> Double
fractionalPoissonPDF :: (PDF (Poisson b) Integer, RealFrac a) => b -> a -> Double
poisson :: Distribution (Poisson b) a => b -> RVar a
poissonT :: forall b a (m :: Type -> Type). Distribution (Poisson b) a => b -> RVarT m a
newtype Poisson b a
Poisson :: b -> Poisson b a
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Num.Integer.Integer => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Double
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Num.Integer.Integer => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Float
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Int) => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Int
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int16) => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int16
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int32) => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int32
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int64) => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int64
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int8) => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int8
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Num.Integer.Integer) => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Num.Integer.Integer
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Word) => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Word
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word16) => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word16
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word32) => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word32
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word64) => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word64
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word8) => Data.Random.Distribution.CDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word8
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Num.Integer.Integer => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Double
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Num.Integer.Integer => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Float
instance (GHC.Internal.Float.RealFloat b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang GHC.Types.Int) b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Int) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Int
instance (GHC.Internal.Float.RealFloat b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang GHC.Internal.Int.Int16) b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int16) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int16
instance (GHC.Internal.Float.RealFloat b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang GHC.Internal.Int.Int32) b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int32) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int32
instance (GHC.Internal.Float.RealFloat b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang GHC.Internal.Int.Int64) b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int64) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int64
instance (GHC.Internal.Float.RealFloat b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang GHC.Internal.Int.Int8) b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Int.Int8) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int8
instance (GHC.Internal.Float.RealFloat b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang GHC.Num.Integer.Integer) b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Num.Integer.Integer) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Num.Integer.Integer
instance (GHC.Internal.Float.RealFloat b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang GHC.Types.Word) b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Types.Word) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Word
instance (GHC.Internal.Float.RealFloat b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang GHC.Internal.Word.Word16) b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word16) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word16
instance (GHC.Internal.Float.RealFloat b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang GHC.Internal.Word.Word32) b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word32) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word32
instance (GHC.Internal.Float.RealFloat b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang GHC.Internal.Word.Word64) b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word64) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word64
instance (GHC.Internal.Float.RealFloat b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Gamma.Erlang GHC.Internal.Word.Word8) b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial b) GHC.Internal.Word.Word8) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word8
instance Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Num.Integer.Integer => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Double
instance Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Num.Integer.Integer => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Float
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Int) => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Int
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int16) => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int16
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int32) => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int32
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int64) => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int64
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int8) => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Int.Int8
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Num.Integer.Integer) => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Num.Integer.Integer
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Word) => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Types.Word
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word16) => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word16
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word32) => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word32
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word64) => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word64
instance (GHC.Internal.Real.Real b, Data.Random.Distribution.Distribution (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word8) => Data.Random.Distribution.PDF (Data.Random.Distribution.Poisson.Poisson b) GHC.Internal.Word.Word8

module Data.Random.Distribution.Multinomial
multinomial :: Distribution (Multinomial p) [a] => [p] -> a -> RVar [a]
multinomialT :: forall p a (m :: Type -> Type). Distribution (Multinomial p) [a] => [p] -> a -> RVarT m [a]
data Multinomial p a
[Multinomial] :: forall p a1. [p] -> a1 -> Multinomial p [a1]
instance (GHC.Internal.Num.Num a, GHC.Classes.Eq a, GHC.Internal.Real.Fractional p, Data.Random.Distribution.Distribution (Data.Random.Distribution.Binomial.Binomial p) a) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Multinomial.Multinomial p) [a]

module Data.Random.Distribution.Bernoulli

-- | Generate a Bernoulli variate with the given probability. For
--   Bool results, bernoulli p will return True (p*100)%
--   of the time and False otherwise. For numerical types, True is replaced
--   by 1 and False by 0.
bernoulli :: Distribution (Bernoulli b) a => b -> RVar a

-- | Generate a Bernoulli process with the given probability. For
--   Bool results, bernoulli p will return True (p*100)%
--   of the time and False otherwise. For numerical types, True is replaced
--   by 1 and False by 0.
bernoulliT :: forall b a (m :: Type -> Type). Distribution (Bernoulli b) a => b -> RVarT m a

-- | A random variable whose value is True the given fraction of the
--   time and False the rest.
boolBernoulli :: forall a (m :: Type -> Type). (Fractional a, Ord a, Distribution StdUniform a) => a -> RVarT m Bool
boolBernoulliCDF :: Real a => a -> Bool -> Double

-- | generalBernoulli t f p generates a random variable whose
--   value is t with probability p and f with
--   probability 1-p.
generalBernoulli :: forall b a (m :: Type -> Type). Distribution (Bernoulli b) Bool => a -> a -> b -> RVarT m a
generalBernoulliCDF :: CDF (Bernoulli b) Bool => (a -> a -> Bool) -> a -> a -> b -> a -> Double
newtype Bernoulli b a
Bernoulli :: b -> Bernoulli b a
instance (Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool, GHC.Internal.Real.Real b) => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool
instance (Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool, GHC.Internal.Float.RealFloat a) => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) (Data.Complex.Complex a)
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Double
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Float
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Int
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Int.Int16
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Int.Int32
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Int.Int64
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Int.Int8
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Num.Integer.Integer
instance (Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool, GHC.Internal.Real.Integral a) => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) (GHC.Internal.Real.Ratio a)
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Word
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Word.Word16
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Word.Word32
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Word.Word64
instance Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.CDF (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Word.Word8
instance (GHC.Internal.Real.Fractional b, GHC.Classes.Ord b, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform b) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool
instance (Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool, GHC.Internal.Float.RealFloat a) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) (Data.Complex.Complex a)
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Double
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Float
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Int
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Int.Int16
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Int.Int32
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Int.Int64
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Int.Int8
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Num.Integer.Integer
instance (Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool, GHC.Internal.Real.Integral a) => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) (GHC.Internal.Real.Ratio a)
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Word
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Word.Word16
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Word.Word32
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Word.Word64
instance Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Types.Bool => Data.Random.Distribution.Distribution (Data.Random.Distribution.Bernoulli.Bernoulli b) GHC.Internal.Word.Word8

module Data.Random.Sample

-- | 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.
class Sampleable (d :: Type -> Type) (m :: Type -> Type) t

-- | Directly sample from a distribution or random variable, using the
--   given source of entropy.
sampleFrom :: (Sampleable d m t, StatefulGen g m) => g -> d t -> m t

-- | Sample a random variable using the default source of entropy for the
--   monad in which the sampling occurs.
sample :: (Sampleable d m t, StatefulGen g m, MonadReader g m) => d t -> m t

-- | 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)
sampleState :: (Distribution d t, RandomGen g, MonadState g m) => d t -> m t

-- | Sample a random variable in a "functional" style. Typical
--   instantiations of g are System.Random.StdGen or
--   System.Random.Mersenne.Pure64.PureMT.
samplePure :: (Distribution d t, RandomGen g) => d t -> g -> (t, g)
instance Data.Random.Lift.Lift m n => Data.Random.Sample.Sampleable (Data.RVar.RVarT m) n t
instance Data.Random.Distribution.Distribution d t => Data.Random.Sample.Sampleable d m t

-- | 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.
module Data.Random

-- | 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
--   
type RVar = RVarT Identity

-- | 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
--   
data RVarT (m :: Type -> Type) a

-- | "Run" an RVar - samples the random variable from the provided
--   source of entropy.
runRVar :: StatefulGen g m => RVar a -> g -> m a

-- | Like runRVarTWith, but using an implicit lifting (provided by
--   the Lift class)
runRVarT :: forall (n :: Type -> Type) m g a. (Lift n m, StatefulGen g m) => 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.
runRVarTWith :: forall m n g a. StatefulGen g m => (forall t. () => n t -> m t) -> RVarT n a -> g -> m a

-- | 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.
class Distribution (d :: Type -> Type) t

-- | Return a random variable with this distribution.
rvar :: Distribution d t => d t -> RVar t

-- | 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.
rvarT :: forall (n :: Type -> Type). Distribution d t => d t -> RVarT n t
class Distribution d t => CDF (d :: Type -> Type) t

-- | 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).
cdf :: CDF d t => d t -> t -> Double
class Distribution d t => PDF (d :: Type -> Type) t
pdf :: PDF d t => d t -> t -> Double
logPdf :: PDF d t => d t -> t -> Double

-- | 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.
class Sampleable (d :: Type -> Type) (m :: Type -> Type) t

-- | Directly sample from a distribution or random variable, using the
--   given source of entropy.
sampleFrom :: (Sampleable d m t, StatefulGen g m) => g -> d t -> m t

-- | Sample a random variable using the default source of entropy for the
--   monad in which the sampling occurs.
sample :: (Sampleable d m t, StatefulGen g m, MonadReader g m) => d t -> m t

-- | 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)
sampleState :: (Distribution d t, RandomGen g, MonadState g m) => d t -> m t

-- | Sample a random variable in a "functional" style. Typical
--   instantiations of g are System.Random.StdGen or
--   System.Random.Mersenne.Pure64.PureMT.
samplePure :: (Distribution d t, RandomGen g) => d t -> g -> (t, g)

-- | A definition of a uniform distribution over the type t. See
--   also uniform.
data Uniform 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.
Uniform :: !t -> !t -> Uniform t
uniform :: Distribution Uniform a => a -> a -> RVar a
uniformT :: forall a (m :: Type -> Type). Distribution Uniform a => a -> a -> RVarT m a

-- | 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).
data StdUniform t
StdUniform :: StdUniform t

-- | 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).
stdUniform :: Distribution StdUniform a => RVar a

-- | 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).
stdUniformT :: forall a (m :: Type -> Type). Distribution StdUniform a => RVarT m a

-- | A specification of a normal distribution over the type a.
data Normal a

-- | The "standard" normal distribution - mean 0, stddev 1
StdNormal :: Normal a

-- | Normal m s is a normal distribution with mean m and
--   stddev sd.
Normal :: a -> a -> Normal a

-- | normal m s is a random variable with distribution
--   Normal m s.
normal :: Distribution Normal a => a -> a -> RVar a

-- | stdNormal is a normal variable with distribution
--   StdNormal.
stdNormal :: Distribution Normal a => RVar a

-- | normalT m s is a random process with distribution
--   Normal m s.
normalT :: forall a (m :: Type -> Type). Distribution Normal a => a -> a -> RVarT m a

-- | stdNormalT is a normal process with distribution
--   StdNormal.
stdNormalT :: forall a (m :: Type -> Type). Distribution Normal a => RVarT m a
data Gamma a
Gamma :: a -> a -> Gamma a
gamma :: Distribution Gamma a => a -> a -> RVar a
gammaT :: forall a (m :: Type -> Type). Distribution Gamma a => a -> a -> RVarT m a

-- | StatefulGen is an interface to monadic pseudo-random number
--   generators.
class Monad m => StatefulGen g (m :: Type -> Type)

-- | RandomGen is an interface to pure pseudo-random number
--   generators.
--   
--   StdGen is the standard RandomGen instance provided by
--   this library.
class RandomGen g

-- | 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."
randomElement :: [a] -> RVar a

-- | A random variable that returns the given list in an arbitrary shuffled
--   order. Every ordering of the list has equal probability.
shuffle :: [a] -> RVar [a]

-- | 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.
shuffleN :: Int -> [a] -> RVar [a]

-- | A random variable that selects N arbitrary elements of a list of known
--   length M.
shuffleNofM :: Int -> Int -> [a] -> RVar [a]

module Data.Random.Distribution.Pareto
pareto :: Distribution Pareto a => a -> a -> RVar a
paretoT :: forall a (m :: Type -> Type). Distribution Pareto a => a -> a -> RVarT m a
data Pareto a
Pareto :: !a -> !a -> Pareto a
instance (GHC.Internal.Real.Real a, Data.Random.Distribution.Distribution Data.Random.Distribution.Pareto.Pareto a) => Data.Random.Distribution.CDF Data.Random.Distribution.Pareto.Pareto a
instance (GHC.Internal.Float.Floating a, Data.Random.Distribution.Distribution Data.Random.Distribution.Uniform.StdUniform a) => Data.Random.Distribution.Distribution Data.Random.Distribution.Pareto.Pareto a

module Data.Random.Vector

-- | Take a random element of a vector.
randomElement :: Vector a -> RVar a
