StatWrap is a Python package I've written for this course. Find the documentation here.
I simplify other packages and use function names that match the conventions of {cite}freedman2007statistics
or Google Sheets to make it easier to switch from the book to coding. Other packages use defaults that might clash with the book (e.g. SD vs SD+). Using StatWrap prevents accidentally wading into those complications.
If you pursue more advanced study of statistics or related fields, you will never use StatWrap again, but it's a good place to start if you already find coding to be overwhelming enough.
StatWrap is not installed in Google Colab by default. To install and use statwrap, run !pip install statwrap
. This will produce a lot of output you can ignore. Then you can import the package like in the code below.
!pip install statwrap
import statwrap
%use_fpp
%use_sheets
Requirement already satisfied: statwrap in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (0.2.10) Requirement already satisfied: pandas in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from statwrap) (2.0.3) Requirement already satisfied: numpy in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from statwrap) (1.24.3) Requirement already satisfied: scipy in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from statwrap) (1.11.1) Requirement already satisfied: IPython in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from statwrap) (8.15.0) Requirement already satisfied: matplotlib in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from statwrap) (3.7.2) Requirement already satisfied: backcall in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from IPython->statwrap) (0.2.0) Requirement already satisfied: decorator in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from IPython->statwrap) (5.1.1) Requirement already satisfied: jedi>=0.16 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from IPython->statwrap) (0.18.1) Requirement already satisfied: matplotlib-inline in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from IPython->statwrap) (0.1.6) Requirement already satisfied: pickleshare in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from IPython->statwrap) (0.7.5) Requirement already satisfied: prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from IPython->statwrap) (3.0.36) Requirement already satisfied: pygments>=2.4.0 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from IPython->statwrap) (2.15.1) Requirement already satisfied: stack-data in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from IPython->statwrap) (0.2.0) Requirement already satisfied: traitlets>=5 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from IPython->statwrap) (5.7.1) Requirement already satisfied: pexpect>4.3 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from IPython->statwrap) (4.8.0) Requirement already satisfied: appnope in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from IPython->statwrap) (0.1.2) Requirement already satisfied: contourpy>=1.0.1 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from matplotlib->statwrap) (1.0.5) Requirement already satisfied: cycler>=0.10 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from matplotlib->statwrap) (0.11.0) Requirement already satisfied: fonttools>=4.22.0 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from matplotlib->statwrap) (4.25.0) Requirement already satisfied: kiwisolver>=1.0.1 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from matplotlib->statwrap) (1.4.4) Requirement already satisfied: packaging>=20.0 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from matplotlib->statwrap) (23.1) Requirement already satisfied: pillow>=6.2.0 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from matplotlib->statwrap) (10.0.1) Requirement already satisfied: pyparsing<3.1,>=2.3.1 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from matplotlib->statwrap) (3.0.9) Requirement already satisfied: python-dateutil>=2.7 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from matplotlib->statwrap) (2.8.2) Requirement already satisfied: pytz>=2020.1 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from pandas->statwrap) (2023.3.post1) Requirement already satisfied: tzdata>=2022.1 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from pandas->statwrap) (2023.3) Requirement already satisfied: parso<0.9.0,>=0.8.0 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from jedi>=0.16->IPython->statwrap) (0.8.3) Requirement already satisfied: ptyprocess>=0.5 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from pexpect>4.3->IPython->statwrap) (0.7.0) Requirement already satisfied: wcwidth in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30->IPython->statwrap) (0.2.5) Requirement already satisfied: six>=1.5 in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from python-dateutil>=2.7->matplotlib->statwrap) (1.16.0) Requirement already satisfied: executing in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from stack-data->IPython->statwrap) (0.8.3) Requirement already satisfied: asttokens in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from stack-data->IPython->statwrap) (2.0.5) Requirement already satisfied: pure-eval in /Users/alexanderclark/anaconda3/lib/python3.11/site-packages (from stack-data->IPython->statwrap) (0.2.2)
Here's what the lines above do.
sd
to calculate the standard deviation of a list of numbers using the syntax sd(1,2,3)
. You don't have to write statwrap.fpp.sd(1,2,3)
if you run this line.stdevp
to match the STDEVP
function in Google Sheets and Excel.sd(1, 2, 3)
0.816496580927726
stdevp(1, 2, 3)
0.816496580927726