Search

Symbulate Documentation

The Python package Symbulate provides a user friendly framework for conducting simulations involving probability models. The syntax of Symbulate mirrors the "language of probability" and makes it intuitive to specify, run, analyze, and visualize the results of a simulation.

Installing Symbulate

It is recommended that you first install the Anaconda distribution, which is a Python environment with many scientific packages installed (including all of the packages that Symbulate is built on).

The easiest way to install Symbulate is by running the following command at the command line.

pip install symbulate

It is also possible to download and install Symbulate using these instructions.

Getting started with Symbulate

Import Symbulate during a Python session using the following commands. (The second line in an iPython "magic" which enables inline plotting within a Jupyter notebook.)

from symbulate import *
%matplotlib inline

An interactive tutorial providing an introduction to Symbulate is available here.

A few words about Jupyter notebooks

The primary interface with Symbulate is via Jupyter notebooks. A Jupyter notebook is a document with cells containing either markdown text or code that can be executed interactively, with output visible immediately beneath the input. Jupyter notebooks provide a user friendly interface supporting interactive and reproducible programming and documentation.

Each section of these documentation files was written in a Jupyter notebook, in which code cells (In[]:) are followed by any output they produce (Out[]:). Note that Jupyter notebooks only display the output of the last line of code in a cell (aside from code which produces a plot).

1 + 2
3 / 4
0.75

To display the output of multiple commands, place the commands in separate cells. (Cells can be added using the + button on the toolbar.)

1 + 2
3
3 / 4
0.75

Commands can also be placed on the same line, separated with a comma.

1 + 2, 3 / 4
(3, 0.75)

While not necessary, if desired output can be formatted and displayed using Python print statements.

print('{:.3f}'.format(2/3))
0.667

Help documentation can be accessed in Jupyter notebooks in a code cell by using the question mark ? followed by the named of the object for which help is desired (e.g. ?BoxModel.)

A few words about Python

While Symbulate is a Python package, no previous knowledge of Python is required .

The list of numbers could also have been created using range() in Python. Remember that Python indexing starts from 0 by default. Remember also that range gives you all the values, up to, but not including the last value.