## Stick Breaking Process and Dirichlet Process Priors

The stick-breaking process illustrated here provides a prior distribution known as the Dirichlet Process Prior (DPP). The lavender rectangle below represents an unbroken stick. Press the “b” key to break the stick at a random point. Pressing “b” again breaks the stick randomly again, but only in the rightmost section. This process could technically continue forever, as there will always be some interval representing the rightmost section, but once you have no detectable remainder, press the “t” key to throw darts at the stick. This represents one draw from the DPP. The expected number of occupied segments is shown below as “E” and the observed number of occupied segments is shown as “O”.

As a phylogenetic example, the darts might represent sites and the segments substitution rate categories. The expected number of categories is determined by the parameter alpha (the value of which you can change; see the key at the bottom of the page): higher alpha means more categories.

## Details

Notes:

- b key breaks off fraction from the remainder (lavender) using a draw from Beta(1,alpha)
- p key mimics pressing the b key until the remainder is tiny (0.001)
- r key resets everything
- t key throws darts and computes the O statistic
- shift-up/shift-down arrow keys increase/decrease alpha (but smallest value is 0.1)
- shift-right/shift-left arrow keys increase/decrease the number of darts (within the range 10-100)
- E is the expected number of colored rectangles hit by at least one of the n darts
- O is the observed number of colored rectangles hit by at least one dart

## Acknowledgements

This applet makes use of the excellent d3js javascript library. Please see the GitHub site for details about licensing of other libraries that may have been used in the source code for this applet.

## Licence

Creative Commons Attribution 4.0 International. License (CC BY 4.0). To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.