=]      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\(c) 2014 Alp MestanogullariBSD3alpmestan@gmail.com experimentalGHCNoneFTPO  type, equivalent to a ReaderT (] (^ m))This lets you build simple or complex random generation routines without having the generator passed all around and just run the whole thing in the end, most likely by using .Generate a random _ . The whole _ range is used. > mwc int 8354496680947360541Generate a random _ in the given range. > mwc $ intIn (0, 10) 7Generate a random ` . The whole ` range is used. > mwc int8 -65Generate a random ` in the given range > mwc $ int8In (-10, 10) -3Generate a random a . The whole a range is used. > mwc int16 15413Generate a random a in the given range #> mwc $ int16In (-500, 30129) 9501 Generate a random b . The whole b range is used. > mwc int32 1774441747 Generate a random b in the given range. #> mwc $ int32In (-500, 30129) 8012 Generate a random c . The whole c range is used. !> mwc int64 -2596387699802756017 Generate a random c in the given range. '> mwc $ int64In (-2^30, 30) -630614786 Generate a random d . The whole d range is used. > mwc word 3106215968599504888Generate a random d in the given range. > mwc $ wordIn (1, 64) 28Generate a random e . The whole e range is used. > mwc word8 231Generate a random e in the given range > mwc $ word8In (2, 15) 3Generate a random f . The whole f range is used. > mwc word16 31127Generate a random f in the given range. #> mwc $ word16In (2^13, 2^14) 8885Generate a random g . The whole g range is used. > mwc word32 3917666696Generate a random g in the given range.  > mwc $ word32In (100, 330) 125Generate a random h . The whole h range is used. "> mwc word64 12496697905424132339Generate a random h in the given range. -> mwc $ word64In (2^45, 2^46) 59226619151303Generate a random i) between 0 (excluded) and 1 (included) > mwc float 0.11831179Generate a random i in the given range '> mwc $ floatIn (0.20, 3.14) 1.3784513Generate a random j) between 0 (excluded) and 1 (included)  > mwc double 0.7689412928620208Generate a random j in the given range E> mwc $ doubleIn (-30.121121445, 0.129898878612) -13.612464813256999Generate a random k > mwc bool FalseFA generic function for sampling uniformly any type that implements l.All the xxxIn) functions from this module just call m.Take a  value and run it in n:, generating all the random values described by the . It just uses oR so you really should try hard to put your whole random generation logic in  and call \ in the end, thus initialising the generator only once and generating everything with it.See the documentation for o for more about this. > mwc $ (+2) `fmap` int8 34If for some reason you have a  (p s) you can run it from n just like we do with . 0> mwcST $ listOf 4 bool [False,False,True,True]@Repeatedly run a random computation yielding a value of type a, to get a list of random values of type a. e> mwc (listOf 30 float) [ 5.438623e-2,0.78114086,0.4954672,0.5958733,0.47243807,5.883485e-2 , 5.500287e-2,0.79262286,0.5528683,0.7628807,0.80705905,0.15368962 , 0.8654971,0.4560417,0.23922172,0.5069659,0.8130155,0.6559351 , 1.31405e-2,0.25705606,0.7134138,0.79111993,0.7529769,0.10573909 , 0.37731406,0.6289338,0.85156864,0.15691182,0.9910314,8.133593e-2 ] -> mwc (sum `fmap` listOf 30 float) 15.037931 eA function for generating a vector of the given length for values whose types are instances of l.NThis function is generic in the type of vector it returns, any instance of q will do.It's just a wrapper arround r and doesn't really use the s instance of .$But if you want to have a vector of Persons, you have to use !. P> import qualified Data.Vector.Unboxed as V > :set -XScopedTypeVariables > v :: V.Vector Double <- mwc $ vectorOfVariate 10 > V.mapM_ print v 3.8565084196117705e-2 0.575103826646098 0.379710162825715 0.4066991135077237 0.9778431248247549 0.3786223745680838 0.4361789615081698 0.9904407826187301 0.2951087330670904 0.1533350329892028!MA function for generating a vector of the given length with random values  of any type (in contrast to  ).It is generic in the q@ instance it hands you back. It's implemented in terms of t3 and has been benchmarked to perform as well as r on simple types (r6 can't generate values for types that don't have a l instance). U> import qualified Data.Vector.Unboxed as V > :set -XScopedTypeVariables > v :: V.Vector Int <- mwc $ vectorOf 10 int > V.mapM_ print v -3920053790769159788 3983393642052845448 1528310798822685910 3522283620461337684 6451017362937898910 1929485210691770214 8547527164583329795 3298785082692387491 4019024417224980311 -5216301990322376953"  !"  ! BSD3alpmestan@gmail.com experimentalGHCNone;=KN%6T distribution of probabilities over a finite set.&The only requirement is to somehow be able to represent the distribution corresponding to the list given as argument, e.g: $weighted [(True, 0.8), (False, 0.2)];It should also be able to handle the normalization for you.  weighted [(True, 8), (False, 2)]'' is ( with a u layerWhat is that for? The ui lets us express the fact that what we've drawn from the distribution isn't of interest anymore, using 4,, and observing the remaining cases, using 58, to get back to a normal finite distribution. Example: gdata Wine = Good | Bad deriving (Eq, Show) wines :: Finite d => d Wine wines = weighted [(Good, 0.2), (Bad, 0.8)] twoWines :: Finite d => d (Wine, Wine) twoWines = (,) <*> wines <$> wines decentMeal :: FinBayes (Wine, Wine) decentMeal = do (wine1, wine2) <- twoWines -- we only consider the outcomes of 'twoWines' -- where at least one of the two wines is good -- because we're having a nice meal and are looking -- for a decent pair of wine condition (wine1 == Good || wine2 == Good) return (wine1, wine2) -- to view the distribution, applying -- Bayes' rule on our way: exact (bayes decentMeal)(( is just 'EventT []'ZYou can think of 'Fin a' meaning '[Event a]' i.e a list of the possible outcomes of type a# with their respective probability)) monad transformer/It pairs a value with a probability within the m monad,An event, and its probability.~Probability type: wrapper around Double for a nicer Show instance and for more easily enforcing normalization of weights0Get the underlying probability > prob (P 0.1) 0.11+This event never happens (probability of 0) never = Event undefined 02 Create a %L distribution over the values in the list, each with an equal probability G> exact $ uniformly [True, False] [Event True 50.0%,Event False 50.0%]3ASee the outcomes of a finite distribution and their probabilities G> exact $ uniformly [True, False] [Event True 50.0%,Event False 50.0%] ~> data Fruit = Apple | Orange deriving (Eq, Show) > exact $ uniformly [Apple, Orange] [Event Apple 50.0%,Event Orange 50.0%] X> exact $ weighted [(Apple, 0.8), (Orange, 0.2)] [Event Apple 80.0%,Event Orange 20.0%]4This is the core of ' . If the k@ is false, the current computation is shortcuited (sent to a v in u>) and won't be included when running the distribution with 5. See the documentation of ' for an example.5VThis functions discards all the elements of the distribution for which the call to 4 yielded v . While 4 does the mapping to w^ values, this function discards all of those values for which the condition was not met.6Keeps only the xs and remove the w layer in the distribution.yThis function, used by 6', discards all the events holding a v.7Make finite distributions (() citizens of a by simply sampling an element at random while still approximately preserving the distribution > mwc . liftF $ uniformly [True, False] False > mwc . liftF $ uniformly [True, False] True > mwc . liftF $ weighted [("Haskell", 99), ("PHP", 1)] "Haskell"z Look for an ,T in that list that has a probability superior to the one given as an argument.%&'()*+,-./01234567./0,-1)*+%&(327'546%&)*+,-./NoneK/Sample from a continuous distribution from the  statistics package }> import qualified Statistics.Distribution.Normal as Normal > mwc $ continuous (Normal.normalDistr 0 1) -0.7266583064693862This is equivalent to using X from this module.L-Sample from a discrete distribution from the  statistics package d> import qualified Statistics.Distribution.Normal as Normal > mwc $ discrete (Geo.geometric 0.6) 2This is equivalent to using T from this module.MBeta distribution (from Statistics.Distribution.Beta) > mwc $ listOf 10 (beta 81 219) [ 0.23238372272745833,0.252972980515086,0.22708315774257903 , 0.25807200295967214,0.29794072226119983,0.24534701159196015 , 0.24766870269839578,0.2994199351220346,0.2728157476212405,0.2593318159573564 ]NCauchy distribution (from Statistics.Distribution.Cauchy) > mwc $ listOf 10 (cauchy 0 0.1) [ -0.3932758718373347,0.490467375093784,4.2620417667423555e-2 , 3.370509874905657e-2,-8.186484692937862e-2,9.371858212168262e-2 , -1.1095818809115384e-2,3.0353983716155386e-2,0.22759697862410477 , -0.1881828277028582 ]O1Cauchy distribution around 0, with scale 1 (from Statistics.Distribution.Cauchy) > mwc $ listOf 10 cauchyStd [ 9.409701589649838,-7.361963972107541,0.168746305673769 , 5.091825420838711,-0.326080163135388,-1.2989850787629456 , -2.685658063444485,0.22671438734899435,-1.602349559644217e-2 , -0.6476292643908057 ]PChi-squared distribution (from "Statistics.Distribution.ChiSquared) > mwc $ listOf 10 (chiSquare 4) [ 8.068852054279787,1.861584389294606,6.3049415103095265 , 1.0512164068833838,1.6243237867165086,5.284901049954076 , 0.4773242487947021,1.1753876666374887,5.21554771873363 , 3.477574639460651 ]QFisher's F-Distribution (from %Statistics.Distribution.FDistribution) > mwc $ listOf 10 (fisher 4 3) [ 3.437898578540642,0.844120450719367,1.9907851466347173 , 2.0089975147012784,1.3729208790549117,0.9380430357924707 , 2.642389323945247,1.0918121624055352,0.45650856735477335 , 2.5134537326659196 ]RGamma distribution (from Statistics.Distribution.Gamma) > mwc $ listOf 10 (gamma 3 0.1) [ 5.683745415884202e-2,0.20726188766138176,0.3150672538487696 , 0.4250825346490057,0.5586516230326105,0.46897413151474315 , 0.18374916962208182,9.93000480494153e-2,0.6057279704154832 , 0.11070190282993911 ]SLGamma distribution, without checking whether the parameter are valid (from Statistics.Distribution.Gamma) > mwc $ listOf 10 (improperGamma 3 0.1) [ 0.30431838005485,0.4044380297376584,2.8950141419406657e-2 , 0.468271612850147,0.18587792578128381,0.22735854572527045 , 0.5168050216325927,5.896911236207261e-2,0.24654560998405564 , 0.10557650513145429 ]TGeometric distribution.EDistribution of the number of trials needed to get one success. See !Statistics.Distribution.Geometric 8> mwc $ listOf 10 (geometric 0.8) [2,1,1,1,1,1,1,2,1,5]UGeometric distribution.HDistribution of the number of failures before getting one success. See !Statistics.Distribution.Geometric 9> mwc $ listOf 10 (geometric0 0.8) [0,0,0,0,0,1,1,0,0,0]VStudent-T distribution (from  Statistics.Distribution.StudentT) > mwc $ listOf 10 (student 0.2) [ -14.221373473810829,-29.395749168822267,19.448665112984997 , -30.00446058929083,-0.5033202547957609,2.321975597874013 , 0.7884787761643617,-0.1895113832448149,-131.12901170537924 , 1.371956948317759 ]WUniform distribution between a and b (from Statistics.Distribution.Uniform) > mwc $ listOf 10 (uniform 0.1 0.2) [ 0.1711914559256124,0.1275212181343327,0.15347702635758945 , 0.1743662387063698,0.12047749686635312,0.10719840237585587 , 0.10543681342025846,0.13482973080648325,0.19779298960413577 , 0.1681037592576508 ]XNormal distribution (from Statistics.Distribution.Normal) > mwc $ listOf 10 (normal 4 1) [ 3.6815394812555144,3.5958531529526727,3.775960990625964 , 4.413109650155896,4.825826384709198,4.805629590118984 , 5.259267547365003,4.45410634165052,4.886537243027636 , 3.0409409067356954 ]Y>The standard normal distribution (mean = 0, stddev = 1) (from Statistics.Distribution.Normal) > mwc $ listOf 10 standard [ 0.2252627935262769,1.1831885443897947,-0.6577353418647461 , 2.1574536855051853,-0.16983072710637676,0.9667954287638821 , -1.8758605246293683,-0.8578048838241616,1.9516838769731923 , 0.43752574431460434 ]ZOCreate a normal distribution using parameters estimated from the sample (from Statistics.Distribution.Normal) r> mwc . listOf 10 $ normalFromSample $ V.fromList [1,1,1,3,3,3,4 ,4,4,4,4,4,4,4 ,4,4,4,4,4,5,5 ,5,7,7,7] [ 7.1837511677441395,2.388433817342809,5.252282321156134 , 4.988163140851522,0.40102386713467864,4.4840751065620665 , 2.1471370686776874,2.6591948802201046,3.843667372514598 , 1.7650436484843248 ][Exponential distribution (from #Statistics.Distribution.Exponential) > mwc $ listOf 10 (exponential 0.2) [ 5.713524665694821,1.7774315204594584,2.434017573227628 , 5.463202731505528,0.5403008025455847,14.346316301765576 , 7.380393612391503,24.800854500680032,0.8731076703020924 , 6.1661076502236645 ]\.Exponential distribution given a sample (from #Statistics.Distribution.Exponential) > mwc $ listOf 10 (exponentialFromSample $ V.fromList [1,1,1,0]) [ 0.4237050903604833,1.934301502525168,0.7435728843566659 , 1.8720263209574293,0.605750265970631,0.24103955067365979 , 0.6294952762436511,1.660404952631443,0.6448230847113577 , 0.8891555734786789 ] K*the continuous distribution to sample fromL(the discrete distribution to sample fromMshape parameter alphashape parameter betaN central pointscale parameterPnumber of degrees of freedomRshape parameter kscale parameter thetaSshape parameter kscale parameter thetaT success rateXmeanstandard deviationZsample[lambda (scale) parameter%%&'()*+,-./01234567KLMNOPQRSTUVWXYZ[\MNOPQRSTUVWXYZ[\KL(c) 2014 Alp MestanogullariBSD3alpmestan@gmail.com experimentalGHCNoneG  !%&'()*+,-./01234567KLMNOPQRSTUVWXYZ[\{      !"#$%&'()*+,--.//00123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghighjghkghldemgnognpgnqgnrdesdetdeu^_v^_wdex^_ygz{|}~^_g|ggg%probable-0.1.3-DMbdcrDiIFrBmYoy8lactFMath.Probable.Random!Math.Probable.Distribution.FiniteMath.Probable.Distribution Math.ProbableRandTrunRandTintintInint8int8Inint16int16Inint32int32Inint64int64InwordwordInword8word8Inword16word16Inword32word32Inword64word64InfloatfloatIndoubledoubleInbool uniformInmwcmwcSTlistOfvectorOfVariatevectorOf$fApplicativeRandT$fFunctorRandT $fMonadRandTFiniteweightedFinBayesFinEventT runEventTEventPprobnever uniformlyexact conditionbayesonlyJustliftF$fShowP $fMonadEvent$fApplicativeEvent$fFunctorEvent$fMonadTransEventT $fMonadEventT$fApplicativeEventT$fFunctorEventT$fFiniteMaybeT $fFiniteRandT$fFiniteEventT$fEqP$fOrdP $fFractionalP$fNumP$fRealP $fRealFracP $fEqEvent $fShowEvent continuousdiscretebetacauchy cauchyStd chiSquaredfishergamma improperGamma geometric geometric0studentuniformnormalstandardnormalFromSample exponentialexponentialFromSample*mwc-random-0.13.6.0-FVAd7inlLEjCHUPScUTDLtSystem.Random.MWCGen(primitive-0.6.2.0-EI3NK1Xfv9zEcRtyXK2EwZControl.Monad.Primitive PrimStateghc-prim GHC.TypesIntbaseGHC.IntInt8Int16Int32Int64WordGHC.WordWord8Word16Word32Word64FloatDoubleBoolVariateuniformRIOwithSystemRandomGHC.STST&vector-0.12.0.1-LflPw1fguMb6as60UrZpxNData.Vector.Generic.BaseVector uniformVectorGHC.BaseMonadData.Vector.Generic replicateMtransformers-0.5.2.0Control.Monad.Trans.MaybeMaybeTNothingMaybeJust catMaybes'pick