Using the Demos

Welcome to the T32 Statistics Demos. These demos are all written using Jupyter/Python which runs "Notebooks" in your web browser. A notebook consists of "cells" containing text, Python code, or output.

If you look above, you will see a row consisting of buttons and pull-down menus. The most important button is the play button. Each time you press this button, you will step from cell to cell in the Notebook. This may include executing code and generating output.

Python Code

Python code is represented by grey cells, like the one below. Click on the "run cell" button, right-facing triangle with line until you step through the cell and you see the "Hello World" output.

In [1]:
print('Hello world')
Hello world

You can generally ignore the code in these cells, unless you're interested in using it as the basis for your own code (see Working Locally below). However, you may still need to run the cells to see the example output.

If you want to play all cells with one press, look for the right-most button that looks like two downward arrows, two downward arrow-heads Clicking on this button will reset the notebook and run all cells. Alternatively, or if you don't have that button in your tool-bar, use the "Cell" pull-down menu and select "Run All".

Some cells can have interactive code in it. When run, it may create a graph with slides, buttons, or other widgets you can use to interact with it. Try the cell below...

In [2]:
%matplotlib inline

from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
import matplotlib.pyplot as plt
import numpy as np
import math

t = np.arange(0, 2*math.pi, 0.01)

def showSinWave(frequency):
    y = np.sin(frequency * t)
interact(showSinWave, frequency=widgets.FloatSlider(min=1.0, max=20.0, step=0.1, value=2.0));

You can also click on the small "x" above the graph to close the output. This can save resources if the interactive graph does a lot of work.

Working Locally

You can use the "File" pull-down menu to download a notebook to your computer. You can then run it on your machine with your data, or make changes to the notebook and not lose them when you end your session.

In [ ]: