Skip to content
Permalink
f97e01675a
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
1447 lines (1447 sloc) 90.1 KB
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"###### Content modified under Creative Commons Attribution license CC-BY 4.0, code under BSD 3-Clause License © 2020 Ryan C. Cooper"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Cheers! Stats with Beers\n",
"\n",
"\n",
"Welcome to the second module in _Computational Mechanics_, our series in computational thinking for undergraduate engineering students. This module explores practical data and statistical analysis with Python.\n",
"\n",
"This first lesson explores how we can answer questions using data combined with practical methods from statistics.\n",
"\n",
"We'll need some fun data to work with. We found a neat data set of canned craft beers in the US, scraped from the web and cleaned up by Jean-Nicholas Hould ([@NicholasHould](https://twitter.com/NicholasHould?lang=en) on Twitter)—who we want to thank for having a permissive license on his GitHub repository so we can reuse his [work](https://github.com/nickhould/craft-beers-dataset)!\n",
"\n",
"The data source ([@craftcans](https://twitter.com/craftcans) on Twitter) doesn't say that the set includes *all* the canned beers brewed in the country. So we have to asume that the data is a sample and may contain biases.\n",
"\n",
"We'll process the data using **numpy**—the array library for Python that we learned about in [Module 1, lesson 2: Getting Started](../../CompMech01-Getting-started/notebooks/02-Getting-started.ipynb). But we'll also learn about a new Python library for data analysis called **pandas**. \n",
"\n",
"[`pandas`](http://pandas.pydata.org/) is an open-source library providing high-performance, easy-to-use data structures and data-analysis tools. Even though `pandas` is great for data analysis, we won't exploit all its power in this lesson. But we'll learn more about it later on!\n",
"\n",
"We'll use `pandas` to read the data file (in `csv` format, for comma-separated values), display it in a nice table, and extract the columns that we need—which we'll convert to `numpy` arrays to work with.\n",
"\n",
"Let's start by importing the two Python libraries that we need."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 1: Read the data file\n",
"\n",
"Below, we'll take a peek into the data file, `beers.csv,` using the system command `head` (which we can use with a bang, thanks to IPython).\n",
"\n",
"But first, we will download the data using a Python library for opening a URL on the Internet. We created a short URL for the data file in the public repository with our course materials.\n",
"\n",
"The cell below should download the data in your current working directory. The next cell shows you the first few lines of the data."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
",abv,ibu,id,name,style,brewery_id,ounces\n",
"0,0.05,,1436,Pub Beer,American Pale Lager,408,12.0\n",
"1,0.066,,2265,Devil's Cup,American Pale Ale (APA),177,12.0\n",
"2,0.071,,2264,Rise of the Phoenix,American IPA,177,12.0\n",
"3,0.09,,2263,Sinister,American Double / Imperial IPA,177,12.0\n",
"4,0.075,,2262,Sex and Candy,American IPA,177,12.0\n",
"5,0.077,,2261,Black Exodus,Oatmeal Stout,177,12.0\n",
"6,0.045,,2260,Lake Street Express,American Pale Ale (APA),177,12.0\n",
"7,0.065,,2259,Foreman,American Porter,177,12.0\n",
"8,0.055,,2258,Jade,American Pale Ale (APA),177,12.0\n"
]
}
],
"source": [
"!head \"../data/beers.csv\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can use `pandas` to read the data from the `csv` file, and save it into a new variable called `beers`. Let's then check the type of this new variable—rememeber that we can use the function `type()` to do this."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"beers = pd.read_csv('../data/beers.csv')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pandas.core.frame.DataFrame"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(beers)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is a new data type for us: a `pandas DataFrame`. From the `pandas` documentation: \"A `DataFrame` is a 2-dimensional labeled data structure with columns of potentially different types\" [4]. You can think of it as the contens of a spreadsheet, saved into one handy Python variable. If you print it out, you get a nicely laid-out table: "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Unnamed: 0</th>\n",
" <th>abv</th>\n",
" <th>ibu</th>\n",
" <th>id</th>\n",
" <th>name</th>\n",
" <th>style</th>\n",
" <th>brewery_id</th>\n",
" <th>ounces</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>0.050</td>\n",
" <td>NaN</td>\n",
" <td>1436</td>\n",
" <td>Pub Beer</td>\n",
" <td>American Pale Lager</td>\n",
" <td>408</td>\n",
" <td>12.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0.066</td>\n",
" <td>NaN</td>\n",
" <td>2265</td>\n",
" <td>Devil's Cup</td>\n",
" <td>American Pale Ale (APA)</td>\n",
" <td>177</td>\n",
" <td>12.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2</td>\n",
" <td>0.071</td>\n",
" <td>NaN</td>\n",
" <td>2264</td>\n",
" <td>Rise of the Phoenix</td>\n",
" <td>American IPA</td>\n",
" <td>177</td>\n",
" <td>12.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3</td>\n",
" <td>0.090</td>\n",
" <td>NaN</td>\n",
" <td>2263</td>\n",
" <td>Sinister</td>\n",
" <td>American Double / Imperial IPA</td>\n",
" <td>177</td>\n",
" <td>12.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4</td>\n",
" <td>0.075</td>\n",
" <td>NaN</td>\n",
" <td>2262</td>\n",
" <td>Sex and Candy</td>\n",
" <td>American IPA</td>\n",
" <td>177</td>\n",
" <td>12.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2402</th>\n",
" <td>2405</td>\n",
" <td>0.067</td>\n",
" <td>45.0</td>\n",
" <td>928</td>\n",
" <td>Belgorado</td>\n",
" <td>Belgian IPA</td>\n",
" <td>424</td>\n",
" <td>12.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2403</th>\n",
" <td>2406</td>\n",
" <td>0.052</td>\n",
" <td>NaN</td>\n",
" <td>807</td>\n",
" <td>Rail Yard Ale</td>\n",
" <td>American Amber / Red Ale</td>\n",
" <td>424</td>\n",
" <td>12.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2404</th>\n",
" <td>2407</td>\n",
" <td>0.055</td>\n",
" <td>NaN</td>\n",
" <td>620</td>\n",
" <td>B3K Black Lager</td>\n",
" <td>Schwarzbier</td>\n",
" <td>424</td>\n",
" <td>12.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2405</th>\n",
" <td>2408</td>\n",
" <td>0.055</td>\n",
" <td>40.0</td>\n",
" <td>145</td>\n",
" <td>Silverback Pale Ale</td>\n",
" <td>American Pale Ale (APA)</td>\n",
" <td>424</td>\n",
" <td>12.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2406</th>\n",
" <td>2409</td>\n",
" <td>0.052</td>\n",
" <td>NaN</td>\n",
" <td>84</td>\n",
" <td>Rail Yard Ale (2009)</td>\n",
" <td>American Amber / Red Ale</td>\n",
" <td>424</td>\n",
" <td>12.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>2407 rows × 8 columns</p>\n",
"</div>"
],
"text/plain": [
" Unnamed: 0 abv ibu id name \\\n",
"0 0 0.050 NaN 1436 Pub Beer \n",
"1 1 0.066 NaN 2265 Devil's Cup \n",
"2 2 0.071 NaN 2264 Rise of the Phoenix \n",
"3 3 0.090 NaN 2263 Sinister \n",
"4 4 0.075 NaN 2262 Sex and Candy \n",
"... ... ... ... ... ... \n",
"2402 2405 0.067 45.0 928 Belgorado \n",
"2403 2406 0.052 NaN 807 Rail Yard Ale \n",
"2404 2407 0.055 NaN 620 B3K Black Lager \n",
"2405 2408 0.055 40.0 145 Silverback Pale Ale \n",
"2406 2409 0.052 NaN 84 Rail Yard Ale (2009) \n",
"\n",
" style brewery_id ounces \n",
"0 American Pale Lager 408 12.0 \n",
"1 American Pale Ale (APA) 177 12.0 \n",
"2 American IPA 177 12.0 \n",
"3 American Double / Imperial IPA 177 12.0 \n",
"4 American IPA 177 12.0 \n",
"... ... ... ... \n",
"2402 Belgian IPA 424 12.0 \n",
"2403 American Amber / Red Ale 424 12.0 \n",
"2404 Schwarzbier 424 12.0 \n",
"2405 American Pale Ale (APA) 424 12.0 \n",
"2406 American Amber / Red Ale 424 12.0 \n",
"\n",
"[2407 rows x 8 columns]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"beers"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Inspect the table above. The first column is a numbering scheme for the beers. The other columns contain the following data:\n",
"\n",
"- `abv`: Alcohol-by-volume of the beer.\n",
"- `ibu`: International Bittering Units of the beer.\n",
"- `id`: Unique identifier of the beer.\n",
"- `name`: Name of the beer.\n",
"- `style`: Style of the beer.\n",
"- `brewery_id`: Unique identifier of the brewery.\n",
"- `ounces`: Ounces of beer in the can."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 2: Explore the data\n",
"\n",
"In the field of statistics, [Exploratory Data Analysis](https://en.wikipedia.org/wiki/Exploratory_data_analysis) (EDA) has the goal of summarizing the main features of our data, and seeing what the data can tell us without formal modeling or hypothesis-testing. [2]\n",
"\n",
"Let's start by extracting the columns with the `abv` and `ibu` values, and converting them to numpy arrays. One of the advantages of data frames in `pandas` is that we can access a column simply using its header, like this:\n",
"\n",
"```python\n",
"data_frame['name_of_column']\n",
"```\n",
"\n",
"The output of this action is a `pandas Series`. From the documentation: \"a `Series` is a 1-dimensional labeled array capable of holding any data type.\" [4]\n",
"\n",
"Check the type of a column extracted by header:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pandas.core.series.Series"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(beers['abv'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Of course, you can index and slice a data series like you know how to do with strings, lists and arrays. Here, we display the first ten elements of the `abv` series:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 0.050\n",
"1 0.066\n",
"2 0.071\n",
"3 0.090\n",
"4 0.075\n",
"5 0.077\n",
"6 0.045\n",
"7 0.065\n",
"8 0.055\n",
"9 0.086\n",
"Name: abv, dtype: float64"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"beers['abv'][:10]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Inspect the data in the table again: you'll notice that there are `NaN` (not-a-number) elements in both the `abv` and `ibu` columns. Those values mean that there was no data reported for that beer. A typical task when cleaning up data is to deal with these pesky `NaN`s.\n",
"\n",
"Let's extract the two series corresponding to the `abv` and `ibu` columns, clean the data by removing all `NaN` values, and then access the values of each series and assign them to a numpy array. "
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"abv_series = beers['abv']"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2407"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(abv_series)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Another advantage of `pandas` is that it has the ability to handle missing data. The data-frame method `dropna()` returns a new data frame with only the good values of the original: all the null values are thrown out. This is super useful!"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"abv_clean = abv_series.dropna()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check out the length of the cleaned-up `abv` data; you'll see that it's shorter than the original. `NaN`s gone!"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2348"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(abv_clean)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Remember that a a `pandas` _Series_ consists of a column of values, and their labels. You can extract the values via the [`series.values`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.values.html) attribute, which returns a `numpy.ndarray` (multidimensional array). In the case of the `abv_clean` series, you get a one-dimensional array. We save it into the variable name `abv`. "
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"abv = abv_clean.values"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.05 0.066 0.071 ... 0.055 0.055 0.052]\n"
]
}
],
"source": [
"print(abv)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"numpy.ndarray"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(abv)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we repeat the whole process for the `ibu` column: extract the column into a series, clean it up removing `NaN`s, extract the series values as an array, check how many values we lost."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2407"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ibu_series = beers['ibu']\n",
"\n",
"len(ibu_series)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1405"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ibu_clean = ibu_series.dropna()\n",
"\n",
"ibu = ibu_clean.values\n",
"\n",
"len(ibu)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Exercise\n",
"\n",
"Write a Python function that calculates the percentage of missing values for a certain data series. Use the function to calculate the percentage of missing values for the `abv` and `ibu` data sets. \n",
"\n",
"For the original series, before cleaning, remember that you can access the values with `series.values` (e.g., `abv_series.values`)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Important:\n",
"\n",
"Notice that in the case of the variable `ibu` we are missing almost 42% of the values. This is important, because it will affect our analysis. When we do descriptive statistics, we will ignore these missing values, and having 42% missing will very likely cause bias."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 3: Ready, stats, go!\n",
"\n",
"\n",
"Now that we have numpy arrays with clean data, let's see how we can process them to get some useful information. \n",
"\n",
"Focusing on the numerical variables `abv` and `ibu`, we'll walk through some \"descriptive statistics,\" below. In other words, we aim to generate statistics that summarize the data concisely."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Maximum and minimum \n",
"\n",
"The maximum and minimum values of a dataset are helpful as they tell us the _range_ of our sample: the range gives some indication of the _variability_ in the data.\n",
"We can obtain them for our `abv` and `ibu` arrays with the `min()` and `max()` functions from numpy."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**abv**"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"abv_min = np.min(abv)\n",
"abv_max = np.max(abv)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The minimum value for abv is: 0.001\n",
"The maximum value for abv is: 0.128\n"
]
}
],
"source": [
"print('The minimum value for abv is: ', abv_min)\n",
"print('The maximum value for abv is: ', abv_max)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**ibu**"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"ibu_min = np.min(ibu)\n",
"ibu_max = np.max(ibu)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The minimum value for ibu is: 4.0\n",
"The maximum value for ibu is: 138.0\n"
]
}
],
"source": [
"print('The minimum value for ibu is: ', ibu_min)\n",
"print('The maximum value for ibu is: ', ibu_max)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Mean value\n",
"\n",
"The **mean** value is one of the main measures to describe the central tendency of the data: an indication of where's the \"center\" of the data. If we have a sample of $N$ values, $x_i$, the mean, $\\bar{x}$, is calculated by:\n",
"\n",
"\\begin{equation*}\n",
" \\bar{x} = \\frac{1}{N}\\sum_{i} x_i\n",
"\\end{equation*}\n",
"\n",
"In words, that is the sum of the data values divided by the number of values, $N$. \n",
"\n",
"You've already learned how to write a function to compute the mean in [Module 1 Lesson 5](http://go.gwu.edu/engcomp1lesson5), but you also learned that numpy has a built-in `mean()` function. We'll use this to get the mean of the `abv` and `ibu` values."
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"abv_mean = np.mean(abv)\n",
"ibu_mean = np.mean(ibu)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, we'll print these two variables, but we'll use some fancy new way of printing with Python's string formatter, `string.format()`. There's a sweet site dedicated to Python's string formatter, called [PyFormat](https://pyformat.info), where you can learn lots of tricks!\n",
"\n",
"The basic trick is to use curly brackets `{}` as placeholder for a variable value that you want to print in the middle of a string (say, a sentence that explains what you are printing), and to pass the variable name as argument to `.format()`, preceded by the string.\n",
"\n",
"Let's try something out…"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The mean value for abv is 0.059773424190800686 and for ibu 42.71316725978647\n"
]
}
],
"source": [
"print('The mean value for abv is {} and for ibu {}'.format(abv_mean, ibu_mean))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ugh! That doesn't look very good, does it? Here's where Python's string formatting gets fancy. We can print fewer decimal digits, so the sentence is more readable. For example, if we want to have four decimal digits, we specify it this way:"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The mean value for abv is 0.0598 and for ibu 42.7132\n"
]
}
],
"source": [
"print('The mean value for abv is {:.4f} and for ibu {:.4f}'.format(abv_mean, ibu_mean))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Inside the curly brackets—the placeholders for the values we want to print—the `f` is for `float` and the `.4` is for four digits after the decimal dot. The colon here marks the beginning of the format specification (as there are options that can be passed before). There are so many tricks to Python's string formatter that you'll usually look up just what you need.\n",
"Another useful resource for string formatting is the [Python String Format Cookbook](https://mkaz.blog/code/python-string-format-cookbook/). Check it out!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Variance and standard deviation\n",
"\n",
"While the mean indicates where's the center of your data, the **variance** and **standard deviation** describe the *spread* or variability of the data. We already mentioned that the _range_ (difference between largest and smallest data values) is also an indication of variability. But the standard deviation is the most common measure of variability.\n",
"\n",
"We really like the way [Prof. Kristin Sainani](https://profiles.stanford.edu/kristin-sainani), of Stanford University, presents this in her online course on [Statistics in Medicine](https://lagunita.stanford.edu/courses/Medicine/MedStats-SP/SelfPaced/about). In her lecture \"Describing Quantitative Data: What is the variability in the data?\", available [on YouTube](https://youtu.be/hlFeEQF5tDc), she asks: _What if someone were to ask you to devise a statistic that gives the avarage distance from the mean?_ Think about this a little bit.\n",
"\n",
"The distance from the mean, for any data value, is $x_i - \\bar{x}$. So what is the average of the distances from the mean? If we try to simply compute the average of all the values $x_i - \\bar{x}$, some of which are negative, you'll just get zero! It doesn't work.\n",
"\n",
"Since the problem is the negative distances from the mean, you might suggest using absolute values. But this is just mathematically inconvenient. Another way to get rid of negative values is to take the squares. And that's how we get to the expression for the _variance_: it is the average of the squares of the deviations from the mean. For a set of $N$ values,\n",
"\n",
"\\begin{equation*}\n",
" \\text{var} = \\frac{1}{N}\\sum_{i} (x_i - \\bar{x})^2\n",
"\\end{equation*}\n",
"\n",
"\n",
"The variance itself is hard to interpret. The problem with it is that the units are strange (they are the square of the original units). The **standard deviation**, the square root of the variance, is more meaningful because it has the same units as the original variable. Often, the symbol $\\sigma$ is used for it:\n",
"\n",
"\\begin{equation*} \n",
" \\sigma = \\sqrt{\\text{var}} = \\sqrt{\\frac{1}{N}\\sum_{i} (x_i - \\bar{x})^2}\n",
"\\end{equation*}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Sample vs. population\n",
"\n",
"The above definitions are used when $N$ (the number of values) represents the entire population. But if we have a _sample_ of that population, the formulas have to be adjusted: instead of dividing by $N$ we divide by $N-1$. This is important, especially when we work with real data since usually we have samples of populations. \n",
"\n",
"The **standard deviation** of a sample is denoted by $s$, and the formula is:\n",
"\n",
"\\begin{equation*} \n",
" s = \\sqrt{\\frac{1}{N-1}\\sum_{i} (x_i - \\bar{x})^2}\n",
"\\end{equation*}\n",
"\n",
"Why? This gets a little technical, but the reason is that if you have a _sample_ of the population, you don't know the _real_ value of the mean, and $\\bar{x}$ is actually an _estimate_ of the mean. That's why you'll often find the symbol $\\mu$ used to denote the population mean, and distinguish it with the sample mean, $\\bar{x}$. Using $\\bar{x}$ to compute the standard deviation introduces a small bias: $\\bar{x}$ is computed _from the sample values_, and the data are on average (slightly) closer to $\\bar{x}$ than the population is to $\\mu$. Dividing by $N-1$ instead of $N$ corrects this bias!\n",
"\n",
"Prof. Sainani explains it by saying that we lost one degree of freedom when we estimated the mean using $\\bar{x}$. For example, say we have 100 people and I give you their mean age, and the actual age for 99 people from the sample: you'll be able to calculate the age of that 100th person. Once we calculated the mean, we only have 99 degrees of freedom left because that 100th person's age is fixed. \n",
"\n",
"Below is a graphical distinction between the _sample_ and the _population_ from [@allison_horst on twitter](https://twitter.com/allison_horst)\n",
"\n",
"![Sample vs Population from @allison_horst](https://pbs.twimg.com/media/EOM8s3fVUAAglHu?format=jpg&name=small)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Let's code!\n",
"\n",
"Now that we have the math sorted out, we can program functions to compute the variance and the standard deviation. In our case, we are working with samples of the population of craft beers, so we need to use the formulas with $N-1$ in the denominator. "
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"def sample_var(array):\n",
" \"\"\" Calculates the variance of an array that contains values of a sample of a \n",
" population. \n",
" \n",
" Arguments\n",
" ---------\n",
" array : array, contains sample of values. \n",
" \n",
" Returns\n",
" -------\n",
" var : float, variance of the array .\n",
" \"\"\"\n",
" \n",
" sum_sqr = 0 \n",
" mean = np.mean(array)\n",
" \n",
" for element in array:\n",
" sum_sqr += (element - mean)**2\n",
" \n",
" N = len(array)\n",
" var = sum_sqr / (N - 1)\n",
" \n",
" return var\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Notice that we used `np.mean()` in our function: do you think we can make this function even more Pythonic? \n",
"\n",
"*Hint:* Yes!, we totally can.\n",
"\n",
"##### Exercise:\n",
"\n",
"Re-write the function `sample_var()` using `np.sum()` to replace the `for`-loop. Name the function `var_pythonic`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We have the sample variance, so we take its square root to get the standard deviation. We can make it a function, even though it's just one line of Python, to make our code more readable:"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"def sample_std(array):\n",
" \"\"\" Computes the standard deviation of an array that contains values\n",
" of a sample of a population.\n",
" \n",
" Arguments\n",
" ---------\n",
" array : array, contains sample of values. \n",
" \n",
" Returns\n",
" -------\n",
" std : float, standard deviation of the array.\n",
" \"\"\"\n",
" \n",
" std = np.sqrt(sample_var(array))\n",
" \n",
" return std"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's call our brand new functions and assign the output values to new variables:"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"abv_std = sample_std(abv)\n",
"ibu_std = sample_std(ibu)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we print these values using the string formatter, only printing 4 decimal digits, we can display our descriptive statistics in a pleasant, human-readable way."
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The standard deviation for abv is 0.0135 and for ibu 25.9541\n"
]
}
],
"source": [
"print('The standard deviation for abv is {:.4f} and for ibu {:.4f}'.format(abv_std, ibu_std))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"These numbers tell us that the `abv` values are quite concentrated around the mean value, while the `ibu` values are quite spread out from their mean. How could we check these descriptions of the data? A good way of doing so is using graphics: various types of plots can tell us things about the data. \n",
"\n",
"We'll learn about _histograms_ in this lesson, and in the following lesson we'll explore _box plots_. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 4: Distribution plots \n",
"\n",
"Every time that we work with data, visualizing it is very useful. Visualizations give us a better idea of how our data behaves. One way of visualizing data is with a frequency-distribution plot known as **histogram**: a graphical representation of how the data is distributed. To make a histogram, first we need to \"bin\" the range of values (divide the range into intervals) and then we count how many data values fall into each interval. The intervals are usually consecutive (not always), of equal size and non-overlapping. \n",
"\n",
"Thanks to Python and Matplotlib, making histograms is easy. We recommend that you always read the documentation, in this case about [histograms](https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.hist.html). We'll show you here an example using the `hist()` function from `pyplot`, but this is just a starting point. \n",
"\n",
"Let's first load the **Matplotlib** module called `pyplot`, for making 2D plots. Remember that to get the plots inside the notebook, we use a special \"magic\" command, `%matplotlib inline`:"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"from matplotlib import pyplot\n",
"%matplotlib inline\n",
"\n",
"#Import rcParams to set font styles\n",
"from matplotlib import rcParams"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(array([ 1., 0., 38., 699., 857., 486., 159., 104., 1., 3.]),\n",
" array([0.001 , 0.0137, 0.0264, 0.0391, 0.0518, 0.0645, 0.0772, 0.0899,\n",
" 0.1026, 0.1153, 0.128 ]),\n",
" <a list of 10 Patch objects>)"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAATY0lEQVR4nO3df4xl5X3f8fcnrAGbyN4FBoR3110sb9LgyMZ0gmldRS2bHwYqL1JAwWnLiqy0kUrauG4ar5NIjqP+AVFUWqSKahWSLFFioCQWq4CckrWTtlEgGX54bUzIjjFhJ0vZsYF1bOQfON/+cZ8xw+zMzt2ZOzM7T98v6eo85znPued7Z+d+5uxzf5xUFZKkvnzPWhcgSRo9w12SOmS4S1KHDHdJ6pDhLkkd2rDWBQCcf/75tW3btrUuQ5LWlUcfffTLVTU237bTIty3bdvGxMTEWpchSetKkr9ZaJvTMpLUIcNdkjpkuEtShwx3SeqQ4S5JHTLcJalDhrskdchwl6QOGe6S1KHT4hOq0mK27X1gTY777C3XrMlx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LeCrq1P2dy1af1U9W1WHgL+fs++PAw9V1YtV9RLwEPD+1Sh6liXXX1V/XVWHW/socAwYW52y53c6hvt8X1+weaExVfUqcJzBmdYw+66k5dQ+208Aj1fVN1eozoUsuf4k5wAfAT6+CnUuZDk//+8DKskftf92/8Iq1DvXcuq/D/g6gzPG54Bfr6oXV7rghWprTuX5t9bP3ZHVkORyBmf+XxxRXUtyOl4ge5ivL1hozFBffbCCllP7YGPyTuBWBmeSq2059X8cuK2qvtZO5NfCcurfAPxT4IeAV4CDSR6tqoOjLfGkllP/5cB3GEwJbAL+d5I/rvYFfqtkOc+/tX7ujqSGJBcBvwPsqqq5/ztZVafjmfswX1/w3THtv6FvAV4cct+VtJzaSbIF+CRwY1WtxV/95dT/XuDXkjwLfAj4xfZhttW03N+dP62qL1fVK8CDwGUrXvECtTWnUv9PAZ+qqm9X1THgz4DV/v6T5Tz/1vq5u+wakrwZeAD45ap6eMS1nbq1nPBf4EWNDQzmbS/mtRc13jlnzM28/kWle1v7nbz+BdVnWN0XVJdT+8Y2/ifW489+zphfYW1eUF3Oz38T8BiDFyM3AH8MXLOO6v8I8FsMzj7PYfAV2+863eqfNfa3OfEF1S+1f4dNrX3uOqr/TOAg8KHVrPmkj2etC1jgB3c18NcM5qx+qfX9KvCB1j6bwTsyJoG/AN4+a99favs9DVy1XmoHfpnBnOkTs24XrJf659zHr7AG4T6C351/xeDF4M8Dv7ae6ge+t/U/ySDY/+NpWv8PMThD/jrwFeDJWfv+dHtck8BN66n+9rvz7TnP30vX4jHM3Pz6AUnq0Ok45y5JWibDXZI6ZLhLUocMd0nqkOEuSR0y3CWpQ4a7JHXo/wHy1WOPssdV+QAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"pyplot.hist(abv)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we have a line plot, but if you see this plot without any information you would not be able to figure out what kind of data it is! We need labels on the axes, a title and why not a better color, font and size of the ticks. \n",
"**Publication quality** plots should always be your standard for plotting. \n",
"How you present your data will allow others (and probably you in the future) to better understand your work. \n",
"\n",
"We can customize the style of our plots using parameters for the lines, text, font and other plot options. We set some style options that apply for all the plots in the current session with [`plt.rc()`](https://matplotlib.org/api/_as_gen/matplotlib.plt.rc.html)\n",
"Here, we'll make the font of a specific type and size (sans-serif and 18 points). You can also customize other parameters like line width, color, and so on (check out the documentation)."
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"#Set font style and size \n",
"rcParams['font.family'] = 'sans'\n",
"rcParams['lines.linewidth'] = 3\n",
"rcParams['font.size'] = 18"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We'll redo the same plot, but now we'll add a few things to make it prettier and **publication quality**. We'll add a title, label the axes and, show a background grid. Study the commands below and look at the result!"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAnsAAAF6CAYAAABhgJ6vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3de7xtU9348c+X45zjUO5PcopTiO4uh1zqQUku6UohKQ/pqlRPT7o8pRKqXyhRj0sXFSHdlCdSSA/iiEKSezlyF47jHOT7+2PMxbKstc/ea6+91trzfN6v13rNvcccc8wxx157r+8eY44xIzORJElSPS0x6ApIkiRp4hjsSZIk1ZjBniRJUo0Z7EmSJNWYwZ4kSVKNGexJkiTVmMGeJPVQRJwTERkRWw66LpIEBnuSJEm1ZrAnSZJUYwZ7kiRJNWawJ0kdRMTWEXFURPwpIu6OiAURcX1EfCMi1hjF8a+s7uG7NyLui4gzI2LTljwvrO7xuzEiokM5z4yIf0XEX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AnSZJUY/8fACWrrC3Q9xQAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 720x360 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"#You can set the size of the figure by doing:\n",
"pyplot.figure(figsize=(10,5))\n",
"\n",
"#Plotting\n",
"pyplot.hist(abv, bins=20, color='b', histtype='bar', edgecolor='white') \n",
"#The \\n is to leave a blank line between the title and the plot\n",
"pyplot.title('abv \\n')\n",
"pyplot.xlabel('Alcohol by Volume (abv) ')\n",
"pyplot.ylabel('Frequency');"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAnsAAAF6CAYAAABhgJ6vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deZgtVXn3/e8PDnAEFBRO0IMC0TgbhwgKaBSnRHGKMRjlwYiCqFEcgq+PAw+iGDEqQkSNAQdAxQEV1KgRiUIwgIARFUVEJpUjCILMBzh4v39Ubdhsdvfp3j3s7urv57r2Vd2rVlXde3V177vXqqqVqkKSJEndtM64A5AkSdLcMdmTJEnqMJM9SZKkDjPZkyRJ6jCTPUmSpA4z2ZMkSeowkz1JmoIkleROz6qaqFySFgqTPUmSpA5bNu4AJGmRePC4A5CkUcQZNCRpdL0h3KrKuGORpGEcxpWkKVjbtXlpvDrJj5PcmOR3SY5Icu8hdXdv93fEBPvav12//+y9A0lLlcmeJM2OQ9rX74CvAKuBlwDfT7LN+MKStNSZ7EnS7HgZ8PiqempVvRD4M+DzwErgsLFGJmlJM9mTpNnxoar6fu+bqroZ2Bu4AXhaEm/wkDQWJnuSNDs+O1hQVZcDx7ffPmF+w5GkhsmeJM2Oiycov6hd3ulGDUmaD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r+SZraN1w7U+xDNTBzfTHIcsLKtezbNDTODdqIZCj9mGrFoCTPZk+bHITRDMn9H80d8HeBJwO+q6qwkj6L5QH9Ou/5amseGHMHs935QzXO6nklzR+dLaD44zm6/fgR3TvY+CzwKeCHNg1zXobm2b2iyV1UXJ3ks8E6a56RtCvyG5m7cd9WIs31U1f8keT7Ns+8OoLnm6wSaD+7/HmWfAx5JMztBz7U0Q85vrqrPTWH7CX/Ok60bxzkwkao6qe2RfTdN0n41zfWQR9MkU2tLjHr7+fckF9Ak572pxv5A82iXPeZoyHqiNj6R5vx9Fs1lBLfSnLtvZArJW1VVkn8H3p1ki7YHdCr+oY3jzTTv/8c0j9H59kC9f6G5wejFNIncz2j+yXg0w5O93Wh6A78yxTi0xGXyyxQkSYI2yf4i8KIpJr6d0g4/nwccXlX7jjGOe9L0Mr65qj44rji0uJjsSZJu0143tkH1zbHbXrN3Is20YfepqkvHFN5YJXkl8F7gT8d1Y0SSQ2iGkx9ad55VRRrKZE+SdJsky2mmE/sMzbWcm9Fca/lw4F+q6s1jDE/SCLxmT5LU7xaaadSeS3N9W2iSvldX1UfGGZik0dizJ0mS1GE+Z0+SJKnDTPYkSZI6zGRPkiSpw0z2JEmSOsxkT5IkqcNM9iRJkjrs/wdzhSS1vqVjjAAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 720x360 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"#You can set the size of the figure by doing:\n",
"pyplot.figure(figsize=(10,5))\n",
"\n",
"#Plotting\n",
"pyplot.hist(ibu, bins=20, color=(0.9, 0.5, 0, 0.9), histtype='bar', edgecolor='white') \n",
"#The \\n is to leave a blanck line between the title and the plot\n",
"pyplot.title('ibu \\n')\n",
"pyplot.xlabel('International Bittering Units (ibu)')\n",
"pyplot.ylabel('Frequency');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the previous two plots we set the colors in two ways:\n",
"\n",
"1. A string 'b', which specifies blue. We could also choose from: a string representation \n",
"one of \n",
"\n",
" {'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'} = \n",
" {**b**lue, **g**reen, **r**ed, **c**yan, **m**agenta, **y**ellow, blac**k**, **w**hite}\n",
" \n",
"2. A RGB or RGBA (red, green, blue, alpha) tuple of float values in [0, 1] (e.g., (0.1, 0.2, 0.5) or (0.1, 0.2, 0.5, 0.3));\n",
"\n",
"Check out the other formatting options use can use in [Matplotlib colors](https://matplotlib.org/3.1.1/tutorials/colors/colors.html) and [Matplotlib hist command](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.hist.html?highlight=hist#matplotlib.pyplot.hist)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exploratory exercise:\n",
"\n",
"Play around with the plots, change the values of the bins, colors, etc."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Comparing with a normal distribution\n",
"\n",
"A **normal** (or Gaussian) distribution is a special type of distrubution that behaves as shown in the figure: 68% of the values are within one standard deviation $\\sigma$ from the mean; 95% lie within $2\\sigma$; and at a distance of $\\pm3\\sigma$ from the mean, we cover 99.7% of the values. This fact is known as the $3$-$\\sigma$ rule, or 68-95-99.7 (empirical) rule.\n",
"\n",
"<img src=\"../images/std_bell_curve.png\" style=\"width: 800px;\"/> \n",
"\n",
"#### Standard deviation and coverage in a normal distribution. Modified figure based on original from [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Standard_deviation_diagram.svg), the free media repository.\n",
"\n",
"\n",
"Notice that our histograms don't follow the shape of a normal distribution, known as *Bell Curve*. Our histograms are not centered in the mean value, and they are not symetric with respect to it. They are what we call **skewed** to the right (yes, to the _right_). A right (or positive) skewed distribution looks like it's been pushed to the left: the right tail is longer and most of the values are concentrated on the left of the figure. Imagine that \"right-skewed\" means that a force from the right pushes on the curve."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Discussion point\n",
"\n",
"* How do you think that skewness will affect the percentages of coverage by standard deviation compared to the Bell Curve?\n",
"\n",
"* Can we calculate those percentages? \n",
"\n",
"## Exercise\n",
"\n",
"We can calculate skewness and standard deviation in a few lines of Python. But before doing that, we want you to explain in your own words how the following piece of code works. \n",
"\n",
"*Hints:* \n",
"\n",
"1. Check what the logical operation `np.logical_and(1<x, x<4)` returns.\n",
"2. Check what happens if you sum booleans. For example, `True + True`, `True + False` and so on.\n"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2\n"
]
}
],
"source": [
"x = np.array([1,2,3,4])\n",
"num_ele = np.logical_and(1<x, x<4).sum()\n",
"print(num_ele)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, using the same idea, we will calculate the number of elements in each interval of width $(1\\sigma, 2\\sigma, 3\\sigma)$, and get the corresponding percentage. \n",
"\n",
"Since we want to compute this for both of our variables, `abv` and `ibu`, we'll write a function to do so. Study carefully the code below. Better yet, explain it to your neighbor."
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"def std_percentages(x, x_mean, x_std):\n",
" \"\"\" Computes the percentage of coverage at 1std, 2std and 3std from the\n",
" mean value of a certain variable x.\n",
" \n",
" Arguments\n",
" ---------\n",
" x : array, data we want to compute on. \n",
" x_mean : float, mean value of x array.\n",
" x_std : float, standard deviation of x array.\n",
" \n",
" Returns\n",
" -------\n",
" \n",
" per_std_1 : float, percentage of values within 1 standard deviation.\n",
" per_std_2 : float, percentage of values within 2 standard deviations.\n",
" per_std_3 : float, percentage of values within 3 standard deviations. \n",
" \"\"\"\n",
" \n",
" std_1 = x_std\n",
" std_2 = 2 * x_std\n",
" std_3 = 3 * x_std\n",
" \n",
" elem_std_1 = np.logical_and((x_mean - std_1) < x, x < (x_mean + std_1)).sum()\n",
" per_std_1 = elem_std_1 * 100 / len(x) \n",
" \n",
" elem_std_2 = np.logical_and((x_mean - std_2) < x, x < (x_mean + std_2)).sum()\n",
" per_std_2 = elem_std_2 * 100 / len(x) \n",
" \n",
" elem_std_3 = np.logical_and((x_mean - std_3) < x, x < (x_mean + std_3)).sum()\n",
" per_std_3 = elem_std_3 * 100 / len(x) \n",
" \n",
" return per_std_1, per_std_2, per_std_3\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's compute the percentages next. Notice that the function above returns three values. If we want to assign each value to a different variable, we need to follow a specific syntax. In our example this would be:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**abv**"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"abv_std1_per, abv_std2_per, abv_std3_per = std_percentages(abv, abv_mean, abv_std)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's pretty-print the values of our variables so we can inspect them:"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The percentage of coverage at 1 std of the abv_mean is : 74.06 %\n",
"The percentage of coverage at 2 std of the abv_mean is : 94.34 %\n",
"The percentage of coverage at 3 std of the abv_mean is : 99.79 %\n"
]
}
],
"source": [
"print('The percentage of coverage at 1 std of the abv_mean is : {:.2f} %'.format(abv_std1_per))\n",
"print('The percentage of coverage at 2 std of the abv_mean is : {:.2f} %'.format(abv_std2_per))\n",
"print('The percentage of coverage at 3 std of the abv_mean is : {:.2f} %'.format(abv_std3_per))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**ibu**"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"ibu_std1_per, ibu_std2_per, ibu_std3_per = std_percentages(ibu, ibu_mean, ibu_std)"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The percentage of coverage at 1 std of the ibu_mean is : 68.11 %\n",
"The percentage of coverage at 2 std of the ibu_mean is : 95.66 %\n",
"The percentage of coverage at 3 std of the ibu_mean is : 99.72 %\n"
]
}
],
"source": [
"print('The percentage of coverage at 1 std of the ibu_mean is : {:.2f} %'.format(ibu_std1_per))\n",
"print('The percentage of coverage at 2 std of the ibu_mean is : {:.2f} %'.format(ibu_std2_per))\n",
"print('The percentage of coverage at 3 std of the ibu_mean is : {:.2f} %'.format(ibu_std3_per))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Notice that in both cases the percentages are not that far from the values for normal distribution (68%, 95%, 99.7%), especially for $2\\sigma$ and $3\\sigma$. So usually you can use these values as a rule of thumb. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## What we've learned\n",
"\n",
"* Read data from a `csv` file using `pandas`.\n",
"* The concepts of Data Frame and Series in `pandas`.\n",
"* Clean null (NaN) values from a Series using `pandas`.\n",
"* Convert a `panda`s Series into a `numpy` array.\n",
"* Compute maximum and minimum, and range.\n",
"* Revise concept of mean value.\n",
"* Compute the variance and standard deviation.\n",
"* Use the mean and standard deviation to understand how the data is distributed.\n",
"* Plot frequency distribution diagrams (histograms).\n",
"* Normal distribution and 3-sigma rule.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## References\n",
"\n",
"1. [Craft beer datatset](https://github.com/nickhould/craft-beers-dataset) by Jean-Nicholas Hould.\n",
"2. [Exploratory Data Analysis](https://en.wikipedia.org/wiki/Exploratory_data_analysis), Wikipedia article.\n",
"3. _Think Python: How to Think Like a Computer Scientist_ (2012). Allen Downey. Green Tea Press. [PDF available](http://greenteapress.com/thinkpython/thinkpython.pdf)\n",
"4. [Intro to data Structures](https://pandas.pydata.org/pandas-docs/stable/dsintro.html), `pandas` documentation.\n",
"5. _Think Stats: Probability and Statistics for Programmers_ version 1.6.0 (2011). Allen Downey. Green Tea Press. [PDF available](http://greenteapress.com/thinkstats/thinkstats.pdf)\n",
"\n",
"### Recommended viewing\n",
"\n",
"From [\"Statistics in Medicine,\"](https://lagunita.stanford.edu/courses/Medicine/MedStats-SP/SelfPaced/about), a free course in Stanford Online by Prof. Kristin Sainani, we highly recommend that you watch these three lectures: \n",
"* [Describing Quantitative Data: Where is the center?](https://youtu.be/tQ5slNYRcC4)\n",
"* [Describing Quantitative Data: What is the variability in the data?](https://youtu.be/hlFeEQF5tDc)\n",
"* [Variability in the data, continued: examples, bell curve](https://youtu.be/qeG0uNI3DBQ)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
},
"widgets": {
"state": {},
"version": "1.1.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}