*      !"#$%&'() * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I JKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ A class for "liftable" data structures. Conceptually  an extension of  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.  Pack 23 unspecified bits from a  into a   in the range [0,1).  Used to convert a  stdUniform  to a  stdUniform  . @Same as wordToFloat, but also return the unused bits (as the 41  least significant bits of a )  Pack 52 unspecified bits from a  into a   in the range [0,1).  Used to convert a  stdUniform  to a  stdUniform  . ASame as wordToDouble, but also return the unused bits (as the 12  least significant bits of a ) :A source of entropy which can be used in the given monad. !The minimal definition is either  or  .    is defaulted in terms of   )Get a random uniformly-distributed byte.  Get a random 8 uniformly-distributed over the full range of the type.  Get a random  / uniformly-distributed over the interval [0,1) FA typeclass for monads with a chosen source of entropy. For example,  RVarD is such a monad - the source from which it is (eventually) sampled J is the only source from which a random variable is permitted to draw, so H when directly requesting entropy for a random variable these functions  are used. !The minimal definition is either   or  .   is defaulted in terms of  . )Get a random uniformly-distributed byte.  Get a random 8 uniformly-distributed over the full range of the type.  Get a random  / uniformly-distributed over the interval [0,1)        LA random variable with access to operations in an underlying monad. Useful W examples include any form of state for implementing random processes with hysteresis, F or writer monads for implementing tracing of complicated algorithms. 5single combined container allowing all the relevant ? dictionaries (plus the RandomSource item itself) to be passed  with one pointer. An opaque type containing a "random variable" - a value 6 which depends on the outcome of some random process. "Runs" the monad. EA random variable evenly distributed over all unsigned integers from  0 to 2^(8*n)-1, inclusive. EA random variable evenly distributed over all unsigned integers from  0 to 2^n-1, inclusive. On systems that have it, /dev/,random is a handy-dandy ready-to-use source B of nonsense. Keep in mind that on some systems, Linux included, /dev/random  collects "real" entropy, and if you don'$t have a good source of it, such as C special hardware for the purpose or a *lot* of network traffic, it's pretty easy M to suck the entropy pool dry with entropy-intensive applications. For many # purposes other than cryptography, /dev/&urandom is preferable because when it  runs out of real entropy it'&ll still churn out pseudorandom data. A token representing the "standard" entropy source in a   P monad. Its sole purpose is to make the following true (when the types check): ! sampleFrom StdRandom === sample Given a mutable reference to a !" generator, we can make a  = usable in any monad in which the reference can be modified. For example, if x :: TVar PureMT, getRandomWordFromMTRef x can be  used as a  in #, $$, or any monad which is an instance  of <. These functions can also be used to implement additional  % instances for mutable references to !" states.  Similarly, getRandomWordFromMTState x can be used in any "state" ) monad in the mtl sense whose state is a !" generator. 2 Additionally, the standard mtl state monads have   instances 9 which do precisely that, allowing an easy conversion of RVars and  other  Distribution instances to "pure" random variables (e.g., by  ErunState . sample :: Distribution d t => d t -> PureMT -> (t, PureMT).  !"& in the type there can be replaced by StdGen or anything else  satisfying MonadRandom (State s) => s). #Given a mutable reference to a %& generator, we can make a  = usable in any monad in which the reference can be modified. For example, if x :: TVar StdGen, getRandomByteFromRandomGenRef x can be  used as a  in #, $$, or any monad which is an instance  of . It'#s generally probably better to use  $( though, as this one is likely to throw Q away a lot of perfectly good entropy. Better still is to use these 3 functions  together to create a  instance for the reference you' re using,  if one does not already exist. & Similarly, !getRandomWordFromRandomGenState x can be used in any "state" ) monad in the mtl sense whose state is a %& generator. 2 Additionally, the standard mtl state monads have   instances 9 which do precisely that, allowing an easy conversion of RVars and  other  Distribution instances to "pure" random variables. !"#$%&'( !"#$%&'( !"#$%&'( ))) *+,-*+,-*+,- 0@Given an upward-closed predicate on an ordered Fractional type, 3 find the smallest value satisfying the predicate. ./01./01./01 3BReturn the cumulative distribution function of this distribution.  That is, a function taking x :: t" to the probability that the next G 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, 3  should correspond ( to the CDF with respect to that order. In other cases, 3 0 is only required to satisfy the following law:  fmap (cdf d) (rvar d) V must be uniformly distributed over (0,1). Inclusion of either endpoint is optional, # though the preferred range is (0,1]. Thus, 3 ; for a product type should not be a joint CDF as commonly 7 defined, as that definition violates both conditions. ? Instead, it should be a univariate CDF over the product type. 4!A definition of a random variable''s distribution. From the distribution  an D can be created, or the distribution can be directly sampled using   sampleFrom or sample. 51Return a random variable with this distribution. 6QReturn a random variable with the given distribution, pre-lifted to an arbitrary .  Any arbitrary  can also be converted to an 'RVarT m' for an arbitrary m, using  either  or sample. 23456452362334556 IGet a "standard" uniformly distributed value. J For integral types, this means uniformly distributed over the full range J of the type (and hence there is no support for Integer). For fractional @ types, this means uniformly distributed on the interval [0,1). 789:;<=>?@ABCDEFGHI9:H78I;ECDF<=@A>?BG7889::;<=>?@ABCDEFGHIL>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. M!A random variable whose value is ' the given fraction of the time  and ' the rest. OgeneralBernoulli t f p, generates a random variable whose value is t  with probability p and f with probability 1-p. JKLMNOPLMNOPJKJKKLMNOPQRSTUQRSTUQRRSTUVWXYZXVWYZVWWXYZ[\]^_`a[\]^_`a[\]^_\]^_`abcdbcdbcdiLike (2, but for the weights of a discrete distribution. j@Adjust all the weights of a discrete distribution so that they D sum to unity. If not possible, returns the original distribution  unchanged. kISimplify a discrete distribution by combining equivalent events (the new B event will have a weight equal to the sum of all the originals). lISimplify a discrete distribution by combining equivalent events (the new B event will have a weight equal to the sum of all the originals). N The comparator function is used to identify events to combine. Once chosen, K the events and their weights are combined (independently) by the provided ) weight and event aggregation functions. efghijklghefijkleffghijklx"Build the tables to implement the ziggurat algorithm devised by  Marsaglia &7 Tang, attempting to automatically compute the R and V  values.  Arguments: 4 flag indicating whether to mirror the distribution ! * the (one-sided antitone) CDF  * the inverse of the CDF  * the number of bins $ * R, the x value of the first bin  * V, the volume of each bin 4 * an RVar providing a random tuple consisting of: 3 - a bin index, uniform over [0,c) :: Int k - a uniformly distributed fractional value, from -1 to 1 if not mirrored, from 0 to 1 otherwise. < * an RVar sampling from the tail (the region where x > R) y"Build the tables to implement the ziggurat algorithm devised by  Marsaglia &7 Tang, attempting to automatically compute the R and V  values. BArguments are the same as for |mkZigguratRec|, with an additional B argument for the tail distribution as a function of the selected  R value. EBuild a lazy recursive ziggurat. Uses a lazily-constructed ziggurat B as its tail distribution (with another as its tail, ad nauseum).  Arguments: 4 flag indicating whether to mirror the distribution ! * the (one-sided antitone) CDF  * the inverse of the CDF / * the integral of the CDF (definite, from 0) = * the estimated volume under the CDF (from 0 to +infinity) L * the chunk size (number of bins). 64 seems to perform well in practice. 4 * an RVar providing a random tuple consisting of: 3 - a bin index, uniform over [0,c) :: Int k - a uniformly distributed fractional value, from -1 to 1 if not mirrored, from 0 to 1 otherwise. mnopqrstuvwxy mnopqrstuvyxw m nopqrstuvnopqrstuvwxyUDraw from the tail of a normal distribution (the region beyond the provided value), ; returning a negative value if the Bool parameter is True.  Construct a nm+ for sampling a normal distribution, given  logBase 2 c, and the r implementation. Ziggurat target function  inverse of   integral of   volume of  z{|}~ z|{}~ z|{{|}~A typeclass allowing 4 s and s to be sampled. Both may  also be sampled via  or  , but I find it psychologically 9 pleasing to be able to sample both using this function. [Directly sample from a distribution or random variable, using the given source of entropy. BSample a distribution using the default source of entropy for the % monad in which the sampling occurs. )  !"#$%&'(23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~*+,-./0123456789:;<=>?@?AABCDEFGHIJKLMNOP Q R S T U V W X Y Z [ \ ] ^ _ _ ` ` a b c d e f g h i j k l m n oppqrstuvwxyz{{|}~  !"$%& ''random-fu-0.0.3Data.Random.LiftData.Random.Internal.WordsData.Random.SourceData.Random.RVarData.Random.Source.DevRandomData.Random.Source.StdData.Random.Source.PureMTData.Random.Source.StdGenData.Random.Internal.THData.Random.Internal.FixedData.Random.Internal.FindData.Random.Distribution Data.Random.Distribution.Uniform"Data.Random.Distribution.Bernoulli$Data.Random.Distribution.Exponential!Data.Random.Distribution.Rayleigh#Data.Random.Distribution.TriangularData.Random.List!Data.Random.Distribution.Discrete!Data.Random.Distribution.ZigguratData.Random.Distribution.NormalData.Random.Distribution.GammaData.Random.Distribution.Beta!Data.Random.Distribution.Binomial Data.Random.Distribution.PoissonData.Random.Sample mtl-1.1.0.2Control.Monad.Transbase Data.Wordghc-prim GHC.Typesmersenne-random-pure64-0.2.0.2System.Random.Mersenne.Pure64 System.IOGHC.Concrandom-1.0.0.1 System.RandomGHC.Bool Control.Monad Data.RandomLiftlift buildWord wordToFloatwordToFloatWithExcess wordToDoublewordToDoubleWithExcess RandomSourcegetRandomByteFromgetRandomWordFromgetRandomDoubleFrom MonadRandom getRandomByte getRandomWordgetRandomDoubleRVarTRVarrunRVarrunRVarT nByteInteger nBitInteger DevRandom DevURandom StdRandomgetRandomWordFromMTRefgetRandomByteFromMTRefgetRandomDoubleFromMTRefgetRandomWordFromMTStategetRandomByteFromMTStategetRandomDoubleFromMTStategetRandomByteFromStdGenIOgetRandomWordFromStdGenIOgetRandomDoubleFromStdGenIOgetRandomByteFromRandomGenRefgetRandomWordFromRandomGenRefgetRandomDoubleFromRandomGenRefgetRandomByteFromRandomGenStategetRandomWordFromRandomGenState!getRandomDoubleFromRandomGenState replaceName resolutionOf resolutionOf2mkFixed unMkFixedfindMax findMaxFromfindMin findMinFromCDFcdf DistributionrvarrvarT StdUniformUniformintegralUniformboundedStdUniformboundedEnumStdUniformfloatStdUniformdoubleStdUniformrealFloatStdUniformfixedStdUniformrealStdUniformCDF floatUniform doubleUniformrealFloatUniform fixedUniformrealUniformCDFuniform stdUniform Bernoulli bernoulli boolBernoulliboolBernoulliCDFgeneralBernoulligeneralBernoulliCDF ExponentialExpfloatingExponentialfloatingExponentialCDF exponentialRayleighfloatingRayleighrayleigh rayleighCDF TriangulartriLowertriMidtriUpperrealFloatTriangularrealFloatTriangularCDF randomElementshuffleshuffleNDiscretediscrete empiricalmapDiscreteWeightsnormalizeDiscreteWeightscollectDiscreteEventscollectDiscreteEventsByZiggurat zTable_xszTable_x_ratios zTable_yszGetIU zTailDistzUniformzFunczMirror runZiggurat mkZiggurat_ mkZigguratNormal StdNormal normalPairboxMullerNormalPairknuthPolarNormalPair normalTailrealFloatStdNormaldoubleStdNormalfloatStdNormal stdNormalnormalErlangGammarealFloatGammarealFloatErlanggammaerlangBetafractionalBetafractionalBetaFromIntegralbetaBinomialintegralBinomialintegralBinomialCDFfloatingBinomialfloatingBinomialCDFbinomialPoissonintegralPoissonintegralPoissonCDFfractionalPoissonfractionalPoissonCDFpoisson Sampleable sampleFromsample MonadTransGHC.WordWord64FloatDoubleRVarDictPureMT GHC.IOBaseIOSTMMonadIO RandomGen integralTypesrealFloatTypesreplicateInstancesTrueFalseGHC.Basefmap zigguratTable mkZigguratRecfindBin0normalZnormalF normalFInv normalFInt normalFVol