This website allows you to run probability experiments. You can flip coins, roll dice, and deal cards. You can specify various parameters, explained below.

The conditions for stopping an experiment or run of
experiments and the counts that can be recorded use a
particular syntax.
The basic element is `count(...)`

which counts
the number of occurences of an event within an experiment.
For keeping track between experiments, there
is `total(...)`

.
These can also be used in the "recording" fields.
Logical and mathematical expressions using these can be
used.
Examples are given in the explanations below.

- Type of experiment: You can choose whether to flip coins, roll dice, or deal cards. Some of the other options depend on which you chose.

- Number of coins flipped in each individual experiment.
- (Un)Biased: It is possible to specify a bias for the coins. The bias is the probability of flipping a head.
- (Un)Ordered: When more than one coin is flipped, the results can be recorded either ordered or unordered. If unordered, the results are sorted so that heads are listed first.

- Number of dice rolled in each individual experiment.
- (Un)Biased: It is possible to
specify a bias for the dice.
The biases are given by listing the probabilities of
getting each number in order separated by commas.
Empty entries are allowed: the "left over" probability is
equally distributed between any empty entries.
Thus a bias of
`,,,,,.5`

for a 6-sided die assigns a probability of .5 to rolling a 6 with all other numbers equally likely. - (Un)Ordered: When more than one dice is rolled, the results can be recorded either ordered or unordered. If unordered, the results are sorted so that smaller numbers are listed first.
- Sides: Various standard sized dice are allowed. Note that when, for example, a 12-sided die is used then if needed the values are reported with a leading zero to make them all the same length. So rolling an 11 then a 2 is distinguishable from rolling a 1 then a 12 (1102 versus 0112).

- Number of cards. With cards,
the situation is that there is a pack of cards of a given
size which is shuffled and then a number of hands of a fixed
size are dealt from that pack (without replacement).
So the details to specify are the number of hands, the
size of each hand, and the size of the deck.
At present, the largest deck size is 52.
Hands are considered to be unordered, so are reported in
the natural order with ace low.
Cards are displayed as, for
example,
`4♥`

, but when matching use`C`

,`D`

,`H`

,`S`

for the suits.

- Updating every ...: The website lists all of the experiments, but with a long run it can be slow to update every flip/roll/deal.
- Until: This gives a condition
for when a given run of experiments should be stopped.
The examples are all in terms of coins.
`count() = 10`

Stop when the number of runs is 10.`count(h) = 10`

Stop when the number of heads is 10.`count(h) = 10 or count(t) = 10`

Stop when the number of heads is 10 or the number of tails is 10.`count(hht) = 3`

Stop when the pattern "HHT" has been seen three times.`count(hh,tt) = 1`

When flipping two coins, stop when two heads are followed by two tails.`count(hh) = 1 or count(th) = 1`

Stop when either HH or TH is seen.

- Recording: This records
various counts of things that happen during an experiment.
Separate different counts with commas.
`count()`

Count the number of flips.`count(h), count(t)`

Count the heads and the tails.`count(hh)/count(h)`

Record the ratio of "HH" to "H".

- Repeat until: The basic
experiment can be repeated, this gives a condition on when
to stop.
`total(count() > 10) = 3`

Stop when there have been three experiments that have had at least 10 flips.`total(count(h) > count(t)) = 1`

Stop when an experiment has more heads than tails.`total(1) = 10`

Stop after ten experiments.

- Recording: This records
various counts through the experiments.
`total(count())`

Record the total number of flips overall.`total(count(h))`

Record the total number of heads overall.`total(count(hh) > count(th))`

Record the total number of experiments where the number of HHs is bigger than the number of THs.

Some notes on how the counts and totals are implemented:

- The counts look for an exact match with the pattern at the end of the current list. (On the TODO is to make this more flexible.)
- The patterns are case insensitive.
- If the pattern is
`HH`

and the flips recorded are`HHH`

then the pattern will match twice. - In the totals, it is possible to put expressions that
evaluate to true or false (such as
`count(h) > 3`

). These are counted as 1 for true and 0 for false. So`total(count(h) > 3)`

counts how many times the count of heads is bigger than 3.

- Make the pattern matching more flexible

The code is released under the MIT Licence so if you want to improve it, feel free. It is available on github.