Skip to content
Permalink
master
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
{
"cells": [
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from scipy.stats import norm, t\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import pretty_plots # script to set up LaTex and increase line-width and font size\n",
"\n",
"import check_lab01 as p"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# ME 3263 \n",
"## Lab #1 - Measurements of machining precision and accuracy \n",
"### How can you measure something?\n",
"\n",
"All measurements have traceable standards. There are seven base units in SI -\n",
"meter (length), second (time), Mole (amount of substance), Ampere (electric\n",
"current), Kelvin (temperature), Candela (Luminous intensity), and kilogram\n",
"(mass) [**1**](https://www.nist.gov/pml/weights-and-measures/metric-si/si-units).\n",
"Any measurement you make should have some method to check against a reference.\n",
"In this lab, we will use calipers that measure dimensions i.e. meter\\*10$^{-3}$\n",
"(length) [**2**](./museum-length.pdf). Calipers can always be verified to work with gage blocks. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Sources of measurement variations\n",
"\n",
"No measurement is exact. No surface is compeletely flat. Every measurement you\n",
"make has two types of uncertainties, *systematic* and *random*. *Systematic*\n",
"uncertainties come from faults in your assumptions or equipment. Here are some\n",
"examples for caliper measurements:\n",
"\n",
"- Your calipers were dropped on the floor and bent, now all of your measurements\n",
" will be too long or too short. \n",
"\n",
"- The bar stock was not machined with square edges so each measurement along the\n",
" sides increases or decreases\n",
"\n",
"- You align the calipers with the bar stock, instead of measuring\n",
" point-to-point. Now your measurements are only the maximum length from\n",
" edge-to-edge\n",
"\n",
"*Random* uncertainties are associated with unpredictable (or unforeseen at the\n",
"time) experimental conditions. These can also be due to simplifications of your\n",
"model. Here are some examples for caliper measurements:\n",
"\n",
"- You assume the surface is flat, but it is in fact rough\n",
"\n",
"- The temperature in the room changes the dimensions through thermal expansion\n",
"\n",
"- Your calipers are not aligned parallel to the edges of the bar stock\n",
"\n",
"In theory, all uncertainies could be accounted for by factoring in all physics\n",
"in a problem e.g. Temperature-dependence, Coriolis effect, electrical\n",
"disturbances in your readings. In practice, the diminishing return on investment\n",
"prevents this practice. For something like measuring bar stock, it is more than\n",
"sufficient to report the average and standard deviation with good calipers. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, you will determine the probability that two groups of samples--e.g. group\n",
"A and group B--have the same average length. This process is called the Student\n",
"t-test [2]. The variable, \n",
"\n",
"$t=\\frac{|M_A-M_B|}{\\sqrt{ab}}$\n",
"\n",
"$a=\\frac{N_A+N_B}{N_A N_B}$\n",
"\n",
"$b=\\frac{(N_A-1)S_A^2+(N_B-1)S_B^2}{N_A+N_B-2}$\n",
"\n",
"The t-test is based upon the means $\\mu_1$ and $\\mu_2$, standard deviations, $\\sigma_1$ and $\\sigma_2$, and number of data points, $N_1$ and $N_2$. The t variable for sets of independent variables based upon the difference in means between sample sets as such\n",
"\n",
"$t=\\frac{|\\mu_1-\\mu_2|}{\\sqrt{AB}}$\n",
"\n",
"$A=\\frac{N_1+N_2}{N_1 N_2}$\n",
"\n",
"$B=\\frac{(N_1-1)\\sigma_1^2+(N_2-1)\\sigma_2^2}{N_1+N_2-2}$\n",
"\n",
"is a function of the two group means, $M_A$\n",
"and $M_B$, two group deviations, $S_A$ and $S_B$, and number of samples per\n",
"group, $N_1$ and $N_2$. Calculate $t$ for groups A and B by filling in Table 2. \n",
"\n",
"**Table 2: Determining t for groups A and B**\n",
"\n",
"|Sample | A Length | $(L-M_A)^2$ | B Length | $(L-M_A)^2$|\n",
"| --- | --- | --- | --- | --- |\n",
"|1 | \n",
"|2 | \n",
"|3 | \n",
"|4 | \n",
"|5 | \n",
"|**sum** |\n",
"|$M$ and $S^2$ |$sum/N_A$ | $sum/(N_A-1)$|$sum/N_B$ | $sum/(N_B-1)$\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example calculations in Python\n",
"Compare two groups of samples:\n",
"\n",
"|group| sample 1|sample 2|sample 3|sample 4|sample 5|\n",
"|--- | --- | --- | --- | --- | --- |\n",
"|A|104.14 mm | 101.61 mm | 99.06 mm | 102.87 mm | 106.68 mm |\n",
"|B|104.12 mm | 101.63 mm | 97.79 mm | 101.58 mm | 104.17 mm |"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"example groups A and B have t=0.59\n"
]
}
],
"source": [
"A=np.array([104.14, 101.61 , 99.06, 102.87, 106.68])\n",
"B=np.array([104.12, 101.63 , 97.79, 101.58 , 104.17])\n",
"meanA=np.sum(A)/len(A)\n",
"meanB=np.sum(B)/len(B)\n",
"s2A=np.sum((A-meanA)**2)/(len(A)-1)\n",
"s2B=np.sum((B-meanB)**2)/(len(B)-1)\n",
"a=(len(A)+len(B))/(len(A)*len(B)*1.0)\n",
"b=((len(A)-1)*s2A+(len(B)-1)*s2B)/(len(A)+len(B)-2)\n",
"#tstat=(meanA-meanB)/np.sqrt(s2A/len(A)+s2B/len(B))\n",
"tstat=(meanA-meanB)/np.sqrt(a*b)\n",
"\n",
"print('example groups A and B have t=%1.2f'%tstat)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"df=8\n",
"| p=0.05 | p=0.025 | p=0.01 | p=0.005 |\n",
"| --- | --- | --- | --- |\n",
"| 2.31 | 2.75 | 3.36 | 3.83 |\n"
]
}
],
"source": [
"df=len(A)+len(B)-2\n",
"# Print out the table for df degrees of freedom (N1+N2-2)\n",
"print('df=%i'%df )\n",
"print('| p=0.05 | p=0.025 | p=0.01 | p=0.005 |')\n",
"print('| --- | --- | --- | --- |')\n",
"print(\"| %1.2f | %1.2f | %1.2f | %1.2f |\"%(t.interval(0.95, df)[1],\\\n",
" t.interval(0.975, df)[1],\\\n",
" t.interval(0.99, df)[1],\\\n",
" t.interval(0.995, df)[1]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Problem 1\n",
"\n",
"Groups A and B have different measurements of the mean length. Is it statistically significant?"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"Answer = 1 # replace 1 with 'yes' or 0 'no'"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Whoops, try again\n"
]
},
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p.check_p01(Answer)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7fba089e6f28>"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAEFCAYAAADjUZCuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAU5klEQVR4nO3dQWyj6V3H8e+fsmh6WHaS2agqHS0zHjhUqBIkqQTi1nXgwLHJLlckmilHpDLZvS2nNgMCISRQMkicMx4uiB4gLreeGqcHDhVCSUs1tIIwsx7KYaUK/Tn4ccbrtR078Wsnk+9Hssbv8z7v67+SjH9+3+d9H0dmIknSz8y7AEnS5WAgSJIAA0GSVBgIkiTAQJAkFQaCJAmAn513ARfx5ptv5p07d+ZdhiRdKa1W678zc6m//UoHwp07dzg4OJh3GZJ0pUTEvw9q95SRJAkwECRJhYEgSQKu+BiCJM3DT3/6U54+fcpHH30071JGunHjBrdv3+a1114bq7+BIEkTevr0Ka+//jp37twhIuZdzkCZybNnz3j69Cl3794da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JWfukIa4es9n+x7XWRuq2HbtpnuvDy1Ea8lnYtHCLqu9oF3oTMhWM88MMN8hzKxGPDOpC824Ijhou4xv8kF9YoyEHQtlTntj0sQ7ANfOaP/Q2C59L/HyynBj0t7/wDyIMcDxhLOqzanGUr1CnNyO2kM3XsNMrNZrkh6vww8T7KPGrDenbv+ArUsA6tz+P4CveIMBGkM5ZP9I16e9rl/nrnwI2L5op/sp7EPaRADQZIEOIYgSSoMBEkSYCBIkgoDQZIEGAiSpMJAkCQB8P+7OHSvcA+GfQAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.hist(A,np.linspace(97,105,5),histtype='step',label='A')\n",
"plt.hist(B,np.linspace(97,105,5),histtype='step',label='B')\n",
"plt.xlabel('length (mm)')\n",
"plt.ylabel('counts')\n",
"plt.legend()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Problem 2\n",
"\n",
"Compare two groups of samples:\n",
"\n",
"|group| sample 1|sample 2|sample 3|sample 4|sample 5|\n",
"|-- | --- | --- | --- | --- | --- |\n",
"|A|103.5| 99.0| 104.5| 110.7| 98.4|\n",
"|B|108.8| 117.9| 113.8| 107.7| 112.7|\n",
"\n",
"Calculate the t-statistic and the t-value comparing the average of group A and group B. Is there a statisitically significant difference between the two sets of measurements?\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'degrees_of_freedom' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-8-6ed2945bd8f5>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mtstat\u001b[0m \u001b[0;31m# your work here\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mtvar\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minterval\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0.95\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mdegrees_of_freedom\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mAnswer\u001b[0m \u001b[0;31m# = 'yes' or 'no'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'degrees_of_freedom' is not defined"
]
}
],
"source": [
"tstat # your work here\n",
"tvar=t.interval(0.95,degrees_of_freedom)[1]\n",
"Answer # = 'yes' or 'no'"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Whoops, try again\n"
]
},
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Leave this alone, execute to check the answer\n",
"p.check_p02(tstat,Answer)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Lab Procedure - Measuring tolerances and comparing groups and samples\n",
"\n",
"You are given four groups, A-D, of 5 samples, 1-5. You will use 4-inch calipers to\n",
"measure the lengths of the four groups of samples. Make sure each lab member\n",
"takes measurements. Measure the length of each sample four times, fill\n",
"in Table 1. \n",
"\n",
"**Table 1. Lengths of machined bar stock. Sets A-D, samples 1-5, length\n",
"measurements 1-4. Calculate the average and standard deviation and note the\n",
"lab member.**\n",
"\n",
"|Set | Sample | Length 1 | Length 2 | Length 3 | Length 4 | Average | St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\_\\_\\_\\_\\_\\_|\n",
"|D|5|\\_\\_\\_|\\_\\_\\_|\\_\\_\\_|\\_\\_\\_|\\_\\_\\_\\_\\_\\_|\\_\\_\\_\\_\\_\\_|\\_\\_\\_\\_\\_\\_|\n",
"\n",
"Sample groups A-D were machined with two different methods, a saw and a computer\n",
"numerical control (CNC) mill. There is a roughness associated with the process\n",
"and a randomness associated with the mounting and cutting of the four groups of\n",
"samples. The roughness affects the variation of the multiple measurements on one\n",
"sample i.e. Length 1, 2, 3, and 4. The mounting and cutting process introduces\n",
"variations between A1, A2, etc. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Your Report \n",
"\n",
"**Goal:** Describe the measurements in sets A, B, C, and D. Determine which sets are statistically equivalent/different (do they satisfy the null hypothesis?). Describe the difference in measurement errors between band saw and CNC sample sets.\n",
"\n",
"1. Introduction\n",
"\n",
"2. Methods\n",
" \n",
"3. Results and Discussion\n",
"\n",
"\n",
"4. Conclusion\n",
"\n",
"\n",
"\n",
"### References\n",
"1. [https://www.nist.gov/pml/weights-and-measures/metric-si/si-units](https://www.nist.gov/pml/weights-and-measures/metric-si/si-units)\n",
"\n",
"2. [Layer, H. P. Length—Evolution from Measurement Standard to a Fundamental Constant](./museum-length.pdf)\n",
"\n",
"3. [Uncertainty\n",
"Notes](https://courses.washington.edu/phys431/uncertainty_notes.pdf)\n",
"\n",
"4. [Student\n",
"t-test](https://www.ruf.rice.edu/~bioslabs/tools/stats/ttest.html)\n",
"\n"
]
},
{
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}