h&M@      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                      Safe-Inferred d probability*composition of a list of monadic functions probabilitylike  but returns all intermediate values like Control.Monad.HT.iterateLimit, but counts differently. Is it actually useful this way? probability8While loop with a posteriori check. Loops at least once. probability4While loop with a priori check. Can loop zero times. Safe-Inferred  Safe-Inferred probability'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 that each discretization is normalized as well.) Safe-Inferred9 Safe-Inferred probabilityfiltering distributions  probabilitydistribution generators  probabilityProbability disributionThe 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  class does not allow constraints for result types. The Monad instance is particularly useful because many generic monad functions make sense here, monad transformers can be used and 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 http://www.randomhacks.net/articles/2007/03/15/data-set-monad-haskell-macrosIf you need efficiency, you should remove redundant elements by .  converts to  and back internally and you can hope that the compiler fuses the lists with the intermediate Map structure.#The defined monad is equivalent to WriterT (Product prob) [] a. See  http://www.randomhacks.net/articles/2007/02/21/refactoring-probability-distributions. probabilityCheck 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. probability0can fail because of rounding errors, better use 3 probabilitypretty printing# probability probability.We would like to have an equality test of type +(==) :: T prob a -> T prob a -> T prob Boolthat is consistent with the $ instance. We would certainly define !x==y = norm (liftM2 (==) x y) . However the  class enforces the type !T prob a -> T prob a -> Bool .We could implement this as check for equal distributions. This would be inconsistent with the  instance because it compares entire distributions, not only individual outcomes. Thus we provide this function as  .I would prefer to omit the , instance completely, but unfortunately the  instance requires  as superclass., probabilityTrue  probabilityFalse 6  !"#$%&'()*+,-./0123456789:;6   !"#$%&'()*+,-./0123456789:;0.1/181 Safe-InferredAFGHIGFHI Safe-Inferred!N probability$product of independent distributionsQ probability sixes p n. computes the probability of getting p sixes (>1, ==2, ...) when rolling n dice JKLMNOPQRST LKJMNOPQRST Safe-Inferreda probabilityAlternative way for computing the distribution. It is usually more efficient because we do not need to switch on the healthy state.UWVXZY[\]^_`ab\[XZYUWV]^_`ab Safe-Inferred5klnmopqrstuvwxypolnmkqrstuvwxy Safe-Inferred probability&only boys in a family that has one boy}~}~ Safe-Inferred probability%calculate the full joint distribution probabilityprior burglary 1% probabilityprior earthquake 0.1% probability>conditional probability of alarm given burglary and earthquake probability3conditional probability of john calling given alarm probability3conditional probability of mary calling given alarm probability>what is the probability that mary calls given that john calls?  Safe-Inferred"\ probability do ...; go xy any action after a go is ignored.  Safe-Inferred$ probabilityrandom transition probability random change probabilityRandomized distribution probability Random values probabilityRun random action in  monad. probabilityRun random action without  using a seed. probability converts a list of randomly generated values into a distribution by taking equal weights for all values. Thus dist (replicate n rnd) simulates rnd n times and returns an estimation of the distribution represented by rnd.  Safe-Inferred&s probability Dist a ==> c = Dist .RChange a = a -> Rnd.T a ==> c = Rnd.T = IO probability'returns the final randomized transition probability/returns the whole trace for a k-fold simulation probability/returns the whole trace for a single simulation668  Safe-Inferred) probability8Print distribution as table with configurable precision.0 Safe-Inferred*{ probabilitystatistical analyses  5Multi-parameter type class with functional dependency Safe-Inferred+U probability?@ABCDEFG%&'(HIJKLMNOPQR STUVWXYZ[\]^_`abcdefdghijklmnopqrstudvwxyz{|}~dd   $   I J #     6 & % ( E F           $ . /      O P y  _ ^ `                         -  $ .          Z [ ] \ WXY-G%&'(EFs0dQsDdghhsd#(probability-0.2.8-GSpUL0Ez7s3CYxKaGBdXKONumeric.Probability.Shape Numeric.Probability.Distribution&Numeric.Probability.Example.Profession Numeric.Probability.Example.Dice%Numeric.Probability.Example.Diagnosis Numeric.Probability.Example.Boys!Numeric.Probability.Example.NBoys!Numeric.Probability.Example.AlarmNumeric.Probability.TransitionNumeric.Probability.RandomNumeric.Probability.TraceNumeric.Probability.SimulationNumeric.Probability.PercentageNumeric.Probability.ExpectationNumeric.Probability.Object#Numeric.Probability.Example.Queuing"Numeric.Probability.Example.Barber&Numeric.Probability.Example.Collection%Numeric.Probability.Example.MontyHall#Numeric.Probability.Example.Kruskal%Numeric.Probability.Example.DiceAccum$Numeric.Probability.Example.BayesianNumeric.Probability.Visualize&Numeric.Probability.Example.TreeGrowth$Numeric.Probability.Example.PredatorNumeric.Probability.MonadNumeric.Probability.PrintListNumeric.Probability.ShowDataMapDistfilter Control.MonadguardcomposeTlinearuniformnegExpnormal normalCurveSelectCaseOtherSpreadConsdeconsEventoneOfjust certainly errorMarginapproxliftsizecheckconssumPsortP sortPDescsortElemnormnorm'norm''pretty//%equalchooseenumrelativeshapeextractmapunfoldcondtruth?=<<>>=?abovebelowselect fromFreqsmapMaybeselectPscanP??expectedvariancestdDev $fFractionalT$fNumT$fEqT$fShowT $fFunctorT$fApplicativeT$fMonadT $fEqSelect $fOrdSelect $fShowSelect ProbabilitycorrectAnswers categoriesDiedietwoDicedicetwoSixessixesdrollg3addTwoFindingNegativePositiveStateHealthyIllpDiseasepFalseNegativepFalsePositivedistdistAltp $fEqFinding $fOrdFinding $fShowFinding $fEnumFinding $fEqState $fOrdState $fShowState $fEnumStateFamilyChildBoyGirlbirthfamilyallBoys existsBoy familyWithBoytwoBoyscountBoy countBoysnumBoys $fEqChild $fOrdChild $fShowChildboysnBoys onlyBoys1BurglaryBburglary earthquakealarmjohnmaryPBoolflpbeajmbJointpmj $fEqBurglary $fOrdBurglary$fShowBurglarySpreadTSpreadCChangeid untilLeftfixapplymaybeliftTuniformTlinearTnormalTenumT relativeT ApproxDist Transition DistributionrandomRrunrunSeedprintpickchangeRExpandRSpaceRWalkRTraceExpandSpaceWalkTracewalkmerge zipListWithC~.~..~*.$fCT$fCT0RTransTransRDistpercentshowPfixroundRel////*liftPliftP2 $fRandomT $fFloatingT$fOrdTExpected FromFloat fromFloatToFloattoFloat floatDist $fToFloatT$fToFloatInteger $fToFloatInt$fToFloatFloat$fFromFloatInteger$fFromFloatInt$fFromFloatFloat $fExpectedT $fExpected[]$fExpectedInteger $fExpectedInt$fExpectedFloatfromFrequencies$fCprobExceptT$fCprobT $fCDoubleTREventsREventRProfileEventsSystemQueueProfileTimeeventsystemmEventmServe mTimeStepmSystemrSystem rBuildEventsrmSystem evalSystemunitmaxQueue allWaiting countWaitingwaitinginSystemtotalserveridleidleAvgPCategory ThreeOrLess FourToTen MoreThanTencustServnextCustbarbers customersruns barberEvent barberEvents barberSystemcatperc barberIdle customerWait $fEqCategory $fOrdCategory$fShowCategoryCardRankPlainJackQueenKingAceSuitClubSpadeHeartDiamondMarbleRG Collection selectOneselect1select2bucketjarpRGBpRGplainsfacesisFaceisPlainrankssuitsdeckvalue totalValuedrawdrawFdrawTo16win chanceWin$fEqRank $fOrdRank $fShowRank$fEqSuit $fOrdSuit $fShowSuit $fEnumSuit $fEqMarble $fOrdMarble $fShowMarble StrategyMOutcomeWinLoseStrategyDoorsprizechosenopenedDoorAdoorsstarthideopenswitchstaygameresultevalsimEval firstChoiceswitch'stayMswitchMevalM $fEqOutcome $fOrdOutcome $fShowOutcome$fEqDoor $fOrdDoor $fShowDoorScore gameRoundgameFastgameFastEither gameFastFixgameLeastScoreflattenedMatrix startVector compareMaybecumulaterunExacttracechopmeeting bruteforce runSimulationlatexDielatexMarkedDielatexFromChainlatexChoppedFromChain makeChainsrollcontinuestrategyNodesESPredSTransPStatehappensnetworksourcebingaEbE $fEqNodes $fOrdNodes $fShowNodesVisPlotysxscolor lineStyle lineWidthlabelPlotFun LineStyleSolidDashedDottedDotDashLongDashTwoDashColorBlackBlueGreenRedBrownGrayPurpleDarkGrayCyan LightGreenMagentaOrangeYellowWhiteCustom FigureEnvFEfileNametitlexLabelyLabelfigureplotcolorssetColor autoColorplotDplotRDplotFplotLplotRLyls metaTupleincrdecrfigfigP showParamslegenddrawyvecout0out1 $fShowColor$fShowLineStyle $fEqLineStyle $fEqColor$fShowFigureEnvTreeAliveHitFallenHeightgrowhitfallevolveseedtreehistsimTreesimHistt2h2st2sh2heightp1p2p3p4 heightAtTimep5 heightCurvep6doneev5 $fOrdTree$fEqTree $fShowTreedsv0p0dvdpdvpvpvspsfig1iteratedoWhilewhile whileTraceLinesasLinesshowNQindent printListasTupleasSeqasListasSetasLispasPlainasPlain'asStringasCasesasDefs asParagraphsshowRghc-prim GHC.ClassesOrdbaseGHC.BaseMonadEqfmapjoinGHC.NumNum GHC.TypesIO