I      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~7binary composition, available in GHC-6.8 Control.Monad +composition of a list of monadic functions like % but returns all intermediate values $While loop with a posteriori check. Loops at least once.  While loop with a priori check. Can loop zero times. 'A shape is a mapping from the interval [0,1] to non-negative numbers. -They need not to be normalized (sum up to 1) *because this is done by subsequent steps. @(It would also be impossible to normalize the function in a way 1that each discretization is normalized as well.) 1filtering distributions  distribution generators Probability disribution )The underlying data structure is a list. <Unfortunately we cannot use a more efficient data structure &because the key type must be of class , but the 4 class does not allow constraints for result types. *The Monad instance is particularly useful 6because many generic monad functions make sense here, monad transformers can be used Tand the monadic design allows to simulate probabilistic games in an elegant manner. %We have the same problem like making Data.Set an instance of , see  Lhttp://www.randomhacks.net/articles/2007/03/15/data-set-monad-haskell-macros @If you need efficiency, you should remove redundant elements by .  converts to Data.Map and back internally Xand you can hope that the compiler fuses the lists with the intermediate Map structure. KCheck whether two distributions are equal when neglecting rounding errors. #We do not want to put this into an  instance, "since it is not exact equivalence .and it seems to be too easy to mix it up with liftM2 (==) x y. 0can fail because of rounding errors, better use / pretty printing  !=Give a list of frequencies, they do not need to sum up to 1. "#$%&'4extracting and mapping the domain of a distribution ( with normalization )>unfold a distribution of distributions into one distribution, this is  with normalization. *conditional distribution True False +,&conditional probability, identical to  Dist.filter - Dist.filter in infix form. 4Can be considered an additional monadic combinator, 'which can be used where you would want Control.Monad.guard otherwise. ./01selecting from distributions 234expectation value 5statistical analyses 61  !"#$%&'()*+,-./01234561    !"#$%&'()*+,-./01234561   !"#$%&'()*+,-./01234567=functions to convert a list of transitions into a transition 89functions to convert a list of changes into a transition 9probabilistic generator :deterministic generator ;<<: maps a change function to the result of a transformation (< is somehow a lifted form of () The restricted type of f results from the fact that the  argument to t cannot be changed to b in the result 9 type. =9unfold a distribution of transitions into one transition 3NOTE: The argument transitions must be independent >&Composition of transitions similar to !Numeric.Probability.Monad.compose -but with intermediate duplicate elimination. ?@ABCDEFGHIJKL789:;<=>?@ABCDEFGHIJKL:9;<=>8?@ABCDEF7GHIJKL789:;<=>?@ABCDEFGHIJKLM&calculate the full joint distribution NOPQRSTUVWXprior burglary 1% Yprior earthquake 0.1% Z?conditional probability of alarm given burglary and earthquake [4conditional probability of john calling given alarm \4conditional probability of mary calling given alarm ]^?what is the probability that mary calls given that john calls? MNOPQRSTUVWXYZ[\]^VUTWXYZ[\MNOPQRS]^MNOPQRSNOPQRSTUVWXYZ[\]^_#Two possible causes for one effect `abcdefghijklmnopq_`abcdefghijklmnopqhgfedcijklm_ba`npqo_ba``abcdefghijklmnopqrstuvwxyz{|}~rstuvwxyz{|}~wvsutrxyz{|}~rsuttuvwxyz{|}~0Alternative way for computing the distribution. TIt is usually more efficient because we do not need to switch on the healthy state.  %product of independent distributions  sixes p n% computes the probability of getting  p sixes (>1, ==2, ...) when rolling n dice 'only boys in a family that has one boy  random transition random change Randomized distribution Random values Run random action in  monad. Run random action without  using a seed. 3 converts a list of randomly generated values into 6a distribution by taking equal weights for all values  =walk is a bounded version of the predefined function iterate  converts a list of s 2into a list of randomized distributions, i.e., an , Oby creating a randomized distribution for each list position across all traces 9Print distribution as table with configurable precision.  statistical analyses >Simulation means to repeat a Rnd.change change many times and :to accumulate all results into a distribution. Therefore, @simulation can be regarded as an approximation of distributions through randomization. AThe Sim class allows the overloading of simulation for different @kinds of generators, namely transitions and Rnd.change changes:  (Trans a = a -> Dist a ==> c = Dist .RChange a = a -> Rnd.T a ==> c = Rnd.T = IO(returns the final randomized transition 0returns the whole trace for a k-fold simulation 0returns the whole trace for a single simulation )initial configuration of the game status Steps of the game:  hide the prize  choose a door / open a non-open door, not revealing the prize  apply strategy: switch or stay 5Multi-parameter type class with functional dependency =Give a list of frequencies, they do not need to sum up to 1.   2(customers waiting,validity period of that queue) -customers and their individual serving times  (servingTime, nextArrival)     multiple servers =decrease served customers remaining time by specified amount time until next completion                 !"#$%&'()*+,-avg barber idle time ./avg customer waiting time (unserved customers)  !"#$%&'()*+,-.#$%&'()*"! +,-."!  !"#$%&'()*+,-.(/0123456789:;<=>?@Asee also the proposal   Dhttp://www.haskell.org/pipermail/libraries/2008-February/009270.html BCDEFGHIJKLMNOPmini-blackjack: =draw 2 cards, and if value is less than 14, continue drawing 9until value equals or exceeds 14. if values exceeds 21, you lose, otherwise you win. QRSTUV(/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV(@?ABCD;>=<EFGH6:987054321/IJKLMNOPQRSTUV(/054321123456:987789:;>=<<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[optimal strategy \Gdistribution of the scores that are achieved with the optimal strategy ]WXYZ[\]WXYZ[\]WXYZ[\]=^Visualization output _settings for individual plots `abcdefghijklmnopqrstuvwxyz{|}~global settings for one figure (default settings for figure environment default plotting environment "create a plot from a distribution create a plot from a function create a plot from a list Hwe want to increase the bounds absolutely, account for negative numbers =^_`abcdefghijklmnopqrstuvwxyz{|}~=o~}|{zyxwvutsrqphnmlkjig_`abcdef^=^_`abcdef`abcdefghnmlkjiijklmno~}|{zyxwvutsrqppqrstuvwxyz{|}~    tree growth simulation: + start with seed and run for n generations tree n) : tree distribution after n generations hist n3 : history of tree distributions for n generations Since '(*.)'& is overloaded for Trans and RChange, )we can run the simulation ~. directly to  n *. live.  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOP>?QRS-:;TUVWXYZ[\]^_`abcdefghijklm[nopqrbcstuvwxfyz{|}~bcrbcbc {   O   % & D                $ b  %  J   K Lr[n9$<:;r's     [c !"#$%&'()*+,-./01234566789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopxqrfstuvwxyz{|}~Qprobability-0.2.1Numeric.Probability.Shape Numeric.Probability.DistributionNumeric.Probability.Transition!Numeric.Probability.Example.Alarm$Numeric.Probability.Example.Bayesian Numeric.Probability.Example.Boys%Numeric.Probability.Example.Diagnosis Numeric.Probability.Example.Dice!Numeric.Probability.Example.NBoysNumeric.Probability.RandomNumeric.Probability.TraceNumeric.Probability.PercentageNumeric.Probability.ExpectationNumeric.Probability.Simulation%Numeric.Probability.Example.MontyHallNumeric.Probability.Object#Numeric.Probability.Example.Queuing"Numeric.Probability.Example.Barber&Numeric.Probability.Example.Collection%Numeric.Probability.Example.DiceAccumNumeric.Probability.Visualize$Numeric.Probability.Example.Predator&Numeric.Probability.Example.TreeGrowthNumeric.Probability.MonadNumeric.Probability.ShowNumeric.Probability.PrintListTlinearuniformnegExpnormal normalCurveSelectOtherCaseSpreadConsdeconsEventoneOfjust certainly errorMarginapproxliftsizecheckconssumPsortPsortElemnormnorm'norm''pretty//%chooseenumrelativeshapeextractmapunfoldcondtruth?=<<>>=?above fromFreqsfilterselectPscanP??expectedvariancestdDevSpreadTSpreadCChangeidcomposeapplymaybeliftTuniformTlinearTnormalTenumT relativeTBurglaryBburglary earthquakealarmjohnmaryPBoolDist ProbabilityflpbeajmbJointpmjNodesEASPredSTransPStateStateeventhappensnetworksourcebingaEbEFamilyChildGirlBoybirthfamilyallBoys existsBoy familyWithBoytwoBoyscountBoy countBoysnumBoysFindingPositiveNegativeIllHealthypDiseasepFalseNegativepFalsePositivedistdistAltpDiedietwoDicedicetwoSixessixesdrollg3addTwoboysnBoys onlyBoys1 ApproxDist Transition DistributionrandomRrunrunSeedprintpickchangeRExpandRSpaceRWalkRTraceExpandSpaceWalkTracewalkmerge zipListWithRTransTransRDistpercentshowPfixroundRel//liftPliftP2Expected FromFloat fromFloatToFloattoFloat floatDistC~.~..~*. StrategyMOutcomeLoseWinStrategyDoorsprizechosenopenedDoordoorsstarthideopenswitchstaygameresultevalsimEval firstChoiceswitch'stayMswitchMevalMfromFrequenciesREventsREventRProfileEventsSystemQueueProfileTimesystemmEventmServe mTimeStepmSystemrSystem rBuildEventsrmSystem evalSystemunitmaxQueue allWaiting countWaitingwaitinginSystemtotalserveridleidleAvgPCategory MoreThanTen FourToTen ThreeOrLesscustServnextCustbarbers customersruns barberEvent barberEvents barberSystemcatperc barberIdle customerWaitCardRankAceKingQueenJackPlainSuitDiamondHeartSpadeClubMarbleGR Collection selectOneselect1select2selectbucketjarpRGBpRGplainsfacesisFaceisPlainrankssuitsdeckvalue totalValuedrawdrawFdrawTo16win chanceWinScorerollcontinuestrategyVisPlotysxscolor lineStyle lineWidthlabelPlotFun LineStyleTwoDashLongDashDotDashDottedDashedSolidColorCustomWhiteYellowOrangeMagenta LightGreenCyanDarkGrayPurpleGrayBrownRedGreenBlueBlack FigureEnvFEfileNametitlexLabelyLabelfigureplotcolorssetColor autoColorplotDplotRDplotFplotLplotRLyls metaTupleincrdecrfigfigP showParamslegenddrawyvecout0out1dsv0p0dvdpdvpvpvspsfig1TreeFallenHitAliveHeightgrowhitfallevolveseedtreehistsimTreesimHistt2h2st2sh2heightp1p2p3p4 heightAtTimep5 heightCurvep6doneev5>=>iteratedoWhilewhile whileTraceshowLshowRrepbase GHC.ClassesOrdGHC.BaseMonadEqfmap Control.MonadjoinLinesasLinesshowNQindent printListasTupleasSeqasListasSetasLispasPlainasPlain'asStringasCasesasDefs asParagraphsghc-prim GHC.TypesIO