{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Hughes and Hase Problem 4.10" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A group of six students make the following measurements of the speed of light (all $\\times 10^8\\, \\mbox{m/s}$): $3.03 \\pm 0.04$, $2.99 \\pm 0.02$, $3.00 \\pm 0.05$, $3.05 \\pm 0.04$ and $2.97 \\pm 0.02$. What should the cohort report as their combined result?\n", "\n", "\n", "The best result for the combined speed is the weighted mean:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(2.9921259842519685, 0.011351102608219766)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "speeds = np.array([3.03, 2.99, 2.99, 3.00, 3.05, 2.97])\n", "uncertainties = np.array([0.04, 0.03, 0.02, 0.05, 0.04, 0.02])\n", "weights = 1/uncertainties**2\n", "weightedAvg = np.dot(speeds,weights)/np.sum(weights)\n", "# OR weightedAvg = speeds@weights/np.sum(weights)\n", "alpha_speeds = np.sqrt(1/np.sum(weights))\n", "weightedAvg, alpha_speeds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So, the combined results should be reported as $(2.992 \\pm 0.011) \\times 10^8\\, \\mbox{m/s}$.\n", "\n", "To check this, make the weights all the same and see if we end up with $s/\\sqrt{N}$. If I make all the uncertainties 0.04, I get 0.0163299 for $\\alpha_{\\rm speeds}$. And $0.04/\\sqrt{6}$ is 0.0163299. So, yes, it works in the proper limit.\n", "\n", "Continuing question 4.10: If another student then reports $c = (3.0 \\pm 0.3) \\times 10^8\\, \\mbox{m/s}$, is \n", "there any change to the cohort's combined measurement?\n", "\n", "We don't really need to do the calculation -- I can tell just by looking at this that this new, crappy measurement (look at how large the uncertainty is compared with the other ones!) isn't going to improve our final results. But we'll do the calculation to show that that is the case." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(2.992137240886347, 0.011342985980361566)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# I just copied the previous cell, and added the new data point\n", "speeds = np.array([3.03, 2.99, 2.99, 3.00, 3.05, 2.97, 3.0])\n", "uncertainties = np.array([0.04, 0.03, 0.02, 0.05, 0.04, 0.02, 0.3])\n", "# uncertainties = sp.array([0.04, 0.04, 0.04, 0.04, 0.04, 0.04])\n", "weights = 1.0/uncertainties**2\n", "weightedAvg = np.dot(speeds,weights)/np.sum(weights)\n", "alpha_speeds = np.sqrt(1.0/np.sum(weights))\n", "weightedAvg, alpha_speeds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So, um, yeah, we end up with $(2.992 \\pm 0.011) \\times 10^8\\, \\mbox{m/s}$, exactly as before. It doesn't really make much difference -- this new measurement has a really large uncertainty (0.3 vs. 0.04 or so), so the result is dominated by the other (better) measurements." ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "#### Version information\n", "`version_information` is from J.R. Johansson (jrjohansson at gmail.com); see Introduction to scientific computing with Python for more information and instructions for package installation.\n", "\n", "`version_information` is installed on the linux network at Bucknell" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "%load_ext version_information" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "application/json": { "Software versions": [ { "module": "Python", "version": "3.7.7 64bit [GCC 7.3.0]" }, { "module": "IPython", "version": "7.16.1" }, { "module": "OS", "version": "Linux 3.10.0 1062.9.1.el7.x86_64 x86_64 with centos 7.7.1908 Core" }, { "module": "numpy", "version": "1.18.5" } ] }, "text/html": [ "
SoftwareVersion
Python3.7.7 64bit [GCC 7.3.0]
IPython7.16.1
OSLinux 3.10.0 1062.9.1.el7.x86_64 x86_64 with centos 7.7.1908 Core
numpy1.18.5
Fri Aug 07 09:50:14 2020 EDT
" ], "text/latex": [ "\\begin{tabular}{|l|l|}\\hline\n", "{\\bf Software} & {\\bf Version} \\\\ \\hline\\hline\n", "Python & 3.7.7 64bit [GCC 7.3.0] \\\\ \\hline\n", "IPython & 7.16.1 \\\\ \\hline\n", "OS & Linux 3.10.0 1062.9.1.el7.x86\\_64 x86\\_64 with centos 7.7.1908 Core \\\\ \\hline\n", "numpy & 1.18.5 \\\\ \\hline\n", "\\hline \\multicolumn{2}{|l|}{Fri Aug 07 09:50:14 2020 EDT} \\\\ \\hline\n", "\\end{tabular}\n" ], "text/plain": [ "Software versions\n", "Python 3.7.7 64bit [GCC 7.3.0]\n", "IPython 7.16.1\n", "OS Linux 3.10.0 1062.9.1.el7.x86_64 x86_64 with centos 7.7.1908 Core\n", "numpy 1.18.5\n", "Fri Aug 07 09:50:14 2020 EDT" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "version_information numpy" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "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.7" } }, "nbformat": 4, "nbformat_minor": 1 }