úÎljj      .A probabilistic event with an outcome of type a . See the  function : to actually run the event and randomly pick an outcome. For an explanation of the ' instance, see the DieRoll type in the Numeric.Probability.Game.Dice  module. The C instance compares the two distributions to see if they are equal. M This looks at all the outcomes and sees if their probabilities are equal on ; the left-hand side and the right-hand side. For example,  coinToss == fmap (>= 4) d6, but d12 / = d6 + d6. The B instance will display a horizontal bar-chart of relative outcome M probability. Note: this really is a relative probability -- common factors N are cancelled, and is not a count of the different outcomes. If you wish to  show the raw numbers, use show . outcomes instead. The C instance allows you to modify the outcome values without changing / their associated probabilities. For example,  fmap show d6 changes the outcomes $ into their String representations. The @ instance allows you to join together the results of two events * in a predetermined manner. For example, makeEvent [id, (* 2)] <*> d6 allows E you to roll a d6 that has a 50% chance of being doubled. Note that pure  67 is an event that is certain to produce the outcome 6. The A instance allows you to base the choice of the next event on the - result of the previous event. For example,  coinToss >>= x -> if x then d6  else d4C will roll a d4 50% of the time and a d6 the other 50%. Note that return  67 is an event that is certain to produce the outcome 6.  OGets a list of all the outcomes of the event and their associated probability. P You can be sure that the probabilities will all sum to 1, and that there will U only be one item in the list per outcome. It is possible that some of the outcomes * in the list will have zero probability. GMakes an event that has an equal chance of taking on the value of each K entry in the list. Note that duplicates in the list are permitted and do  have an effect: makeEvent [True, False]# has a 50% chance of giving a True  result, but *makeEvent [True, True, False, False, False] only has a 40% I chance of giving a True result. If you do not want this behaviour, use  makeEvent . nub to remove duplicates. 3The result of passing the empty list is undefined. CGiven a list of events and their associated probabilities, forms a G corresponding event. The probabilities must be non-negative. If the M probabilities do not sum to one, they are all scaled linearly so that their C sum is one. Duplicate items will have their probabilities added. PThe result of passing the empty list, a list containing negative probabilities, > or a list where all the probabilities are zero is undefined. MAn event with a 50% chance of giving True, and a 50% chance of giving False. VActually enacts the event and produces a single result according to the probabilities  in the EventM a parameter. If the EventM a: parameter returns a result equal to the first parameter, P it is changed to be the second parameter; otherwise it is left untouched. For  example replace 4 8 d45 has an equal chance of producing the outcomes 1, 2,  3 and 8, replace 10 0 d10 == z10, and replace 10 20 d6 == d6. QA type synonym for events with an integer outcome (i.e. all standard die rolls). The  instance for  EventM Int* allows you to add the results of two die ' rolls, or subtract them (if it helps, (+) = liftA2 (+)). "Multiplication works as follows. d * e evaluates the first die roll, . then sums that many rolls of the second. So 2 * d6 rolls two d6 and adds 4 the outcomes. However, this definition means that d6 * 2 rolls one d6, / then effectively scales the result by 2. And d6 * d4 rolls one d6, then  rolls that number of d42, adding their results together. The simple rule K when one of the terms is a constant is: use the constant on the left-hand M side to get more dice, and use the constant on the right-hand side to scale  the result. 4A die with an equal chance of rolling 1, 2, 3 or 4. :A die with an equal chance of rolling 1, 2, 3, 4, 5 or 6. @A die with an equal chance of rolling 1, 2, 3, 4, 5, 6, 7 or 8. FA die with an equal chance of rolling 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9. GA die with an equal chance of rolling 1, 2, 3, 4, 5, 6, 7, 8, 9 or 10. 9A die with an equal chance of rolling 1 to 12 inclusive. 9A die with an equal chance of rolling 1 to 20 inclusive. :A die with an equal chance of rolling 1 to 100 inclusive. 9A die with an equal chance of rolling 0 to 99 inclusive. LMakes a die that has an equal chance of achieving the numbers 1 through the  number given. d 4; has an equal chance of producing the outcomes 1, 2, 3 and  4, d 1 is equivalent to return 1 (a certain result of 1), and  dR is undefined for any number below 1. For convenience, all the standard dice are  provided, e.g. d6 = d 6. HMakes a die that has an equal chance of achieving the numbers 0 through & the one less than the number given. z 4" has an equal chance of producing # the outcomes 0, 1, 2 and 3, while z 1 is equivalent to return 0 (a  certain result of 0), and z+ is undefined for any number below 1. For I convenience, several standard dice that can be interpreted with a lower  result of 0 are provided, e.g.  z10 = z 10. JRerolls the die when the specified outcome(s) occur. This has the effect O of removing the outcomes from the set of outcomes and rescaling all the other 3 probabilities linearly to sum to 1. For example:   d6 `rerollOn` [5,6] == d4 4 chancePred (== 12) ((2*d6) `rerollOn` [7]) == 1/30 >With the latter example, the standard chance of 12 on 2d6 is 1/ 36, which  is rescaled by 36/$30, the reciprocal of the chance of not hitting  a 7. A nice synonym for U: actually rolls the die and produces a single result according to the probabilities  in the EventM a parameter.    MGets the probability that the outcome will satisfy the given predicate. For  example: J chancePred (<= 2) d6 == 1/3 -- The chance of getting 2 or less on a d6 P chancePred even d6 == 1/2 -- The chance of rolling an event number on a d6 OGets the probability that the given relation will hold between the two events.  For example: F chanceRel (==) d6 d6 == 1/6 -- The chance of rolling doubles on d6 J chanceRel (>) (2*d6) d12 -- The chance of beating a d12 with two d6 KGets the probability that the given boolean-outcome event will give a True  outcome. For example:   chanceTrue coinToss == 1/2 # chanceTrue ((== 3) <$> d6) == 1/6 (For the latter example,  is more concise.) !      !"#$%&#'()*game-probability-1.0Numeric.Probability.Game.EventNumeric.Probability.Game.DiceNumeric.Probability.Game.QueryEventMoutcomes makeEvent makeEventProbcoinTossenactsubstDieRolld4d6d8z10d10d12d20d100z100dzrerollOnroll chancePred chanceRel chanceTruebaseGHC.NumNum GHC.ClassesEqGHC.ShowShowGHC.BaseFunctorControl.Applicative ApplicativeMonad normEventMshowBars