{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Estimating mean and standard deviation from numerical data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One method is to look for the median. There are 15 data points. The middle value is 4.19365,\n", "meaning 7 values are larger than this and 7 are smaller. The median\n", "can be a poor estimate for the mean if the distribution is very asymmetric,\n", "but these numbers go up to 4.5 and down to 3.9, so it looks like they are fairly well centered on 4.2.\n", "\n", "Using H&H's \"rough and ready\" estimate (p. 11) for the standard deviation, we find that the maximum value minus the mean is about 0.3. Taking 2/3 of that gives a estimated standard deviation of 0.2." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Quantitative check" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "data = np.array([4.1075, 4.39831, 4.19365, 4.20259,\n", "4.26921, 4.13037, 3.97548, 4.51314, 4.01286, 4.0101, 4.15578, 4.35153,\n", "4.30801, 4.21082, 3.94315])" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.1640200187259383" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.std(data,ddof=1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Not too bad!" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/json": { "Software versions": [ { "module": "Python", "version": "3.7.8 64bit [GCC 7.5.0]" }, { "module": "IPython", "version": "7.17.0" }, { "module": "OS", "version": "Linux 3.10.0 1127.19.1.el7.x86_64 x86_64 with centos 7.9.2009 Core" }, { "module": "numpy", "version": "1.19.1" } ] }, "text/html": [ "
SoftwareVersion
Python3.7.8 64bit [GCC 7.5.0]
IPython7.17.0
OSLinux 3.10.0 1127.19.1.el7.x86_64 x86_64 with centos 7.9.2009 Core
numpy1.19.1
Sun Jan 16 15:32:31 2022 EST
" ], "text/latex": [ "\\begin{tabular}{|l|l|}\\hline\n", "{\\bf Software} & {\\bf Version} \\\\ \\hline\\hline\n", "Python & 3.7.8 64bit [GCC 7.5.0] \\\\ \\hline\n", "IPython & 7.17.0 \\\\ \\hline\n", "OS & Linux 3.10.0 1127.19.1.el7.x86\\_64 x86\\_64 with centos 7.9.2009 Core \\\\ \\hline\n", "numpy & 1.19.1 \\\\ \\hline\n", "\\hline \\multicolumn{2}{|l|}{Sun Jan 16 15:32:31 2022 EST} \\\\ \\hline\n", "\\end{tabular}\n" ], "text/plain": [ "Software versions\n", "Python 3.7.8 64bit [GCC 7.5.0]\n", "IPython 7.17.0\n", "OS Linux 3.10.0 1127.19.1.el7.x86_64 x86_64 with centos 7.9.2009 Core\n", "numpy 1.19.1\n", "Sun Jan 16 15:32:31 2022 EST" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%load_ext version_information\n", "%version_information numpy" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.8" } }, "nbformat": 4, "nbformat_minor": 2 }