c) 2000-2003, Lee Spector

This page allows you to test, demonstrate, and experiment with Parrondo's paradox
as explained in "Losing strategies can win by Parrondo's paradox" by Gregory P. Harmer
and Derek Abbot, in *Nature*, Vol. 402, 23/30 December, 1999.

This is probably not completely self-explanatory; if you really want to understand
what's going on then please read the *Nature* article, Parrondo's brief description
of the games, or the materials at Harmer's
home page.

The simulator runs a specified number of trials and reports the average of the results from all of the trials. A single trial consists of a specified number of games played in succession. The number of games per trial and the total number of trials are parameters that can be changed below. For each game the user can play either game "A" or game "B". The allowed policies for choosing which game to play are:

- random choice for each game
- alternation of A, then B, then A, etc.
- alternation with some number of repeats; for example A, A, B, B, A, A, B, B, etc.
- play only game B (not discussed in the background articles, but may be interesting)

The policy is specified via the "Repeats" parameter below; a value of 0 specifies random choices, a value of 1 specifies alternation, and a value of some integer greater than 1 indicates alternation with that number of repeats (for example, use 2 to get A, A, B, B, A, A, B, B, etc.). A negative value (for example -1) specifies that only game B will be played.

As specified in the *Nature* article game A involves a single coin (coin
#1) while game B involves two coins (coin #2 and coin #3). The probability of winning
for each coin is specified as some "Base" value minus a small "Epsilon"
value. The values for Epsilon and the three bases can be specified below. When game
B is played the choice between coins #2 and #3 is chosen as follows:

If the accumulated "capital" (winnings/losses) for the current trial is a multiple of the parameter M then coin #2 is played; otherwise coin #3 is played.

Parameter M can be specified below.

The simulator uses a seedable random number generator that takes two integer seeds. You don't have to change this; the simulator will work fine with the provided default values. If you do want to change the seeds please note that they must be specified between parentheses, that the first number must be an integer in the range [0-31328], and that the second number must be an integer in the range [0-30081].

All of the default values specified below are those used in the *Nature*
article, with the exception of Total Trials. The article specifies 50,000 total but
because that introduces a possibly long delay, and because the results are almost
identical when much smaller values are used, a default of 1,000 has been specified
here.

The output of the simulator reports your average final capital. You start with zero capital, so if this is greater than zero then you have come out ahead on average. The output also reports the "flip load" per coin, averaged over all trials. This indicates the percentage of played games that were decided via flips of coins #1, #2, or #3.

**Note:** No error-checking is performed on the values that you provide below.
If you get strange error messages you have probably entered an invalid value for
one of the parameters. Do not use commas (,) in large numbers. (Use 2000 rather than
2,000.)

Repeats | |

Epsilon | |

p1 Base | |

p2 Base | |

p3 Base | |

M | |

Initial Capital | |

Games per Trial (max 1000) | |

Total Trials (max 10000) | |

Random Seeds |

**Links**

- Juan M.R. Perrondo's home page with links to game descriptions and discussion.
- Gregory Harmer's home page, including some very nice explanations and diagrams, links to publications, etc.
- Nature, International Weekly Journal of Science

**Version History**

Feb 6, 2000: first version

Feb 7, 2000: inserted <br> in output for www version

Feb 11, 2000: fixed bug in flip load computation

Feb 11, 2000: unified code for web/non-web versions

Dec 12, 2000: added argument for initial capital

March 21, 2003: modified for www version running under CMUCL

June 6, 2003: added limits to prevent excessively long runs

**Legalities**

This code uses Chris McConnell's random.cl random number generator to allow for replication of experiments based on integer seed values. Random.cl can be obtained from the CMU Lisp Repository, at http://www.mit.edu/afs/cs.cmu.edu/project/ai-repository/ai/lang/lisp/code/math/random/

The simulator runs under CMU Common Lisp, available from http://www.cons.org/cmucl

March 21, 2003, Lee Spector