An in-class example
An in-class interactive demo on uncertainty
Everyone in class will use the stopwatch on their phone to measure time between Start and Stop. We will watch these three videos
Enter your data here along with : https://goo.gl/npNx1J
from IPython.display import HTML
HTML("""
<div align="middle">
<video controls>
<source src="/intro-exp-phys-book/images/start_stop_animation.m4v" type="video/mp4">
</video></div>""")
HTML("""
<div align="middle">
<video controls>
<source src="/intro-exp-phys-book/images/start_stop_animation_with_countdown_movie.m4v" type="video/mp4">
</video></div>""")
HTML("""
<div align="middle">
<video controls>
<source src="/intro-exp-phys-book/images/start_stop_animation_with_double_countdown.m4v" type="video/mp4">
</video></div>""")
Now let's analyze the data
The Data is here: https://goo.gl/npNx1J
We will just copy and paste it from google docs into this notebook
import numpy as np
import matplotlib.pyplot as plt
temp1 = """
7.48
7.62
7.59
7.55
7.5
7.53
7.56
7.88
7.5
7.63
7.59
7.55
7.62
7.32
7.58
7.8
7.53
7.59
7.54
7.84
8.71
7.6
7.61
7.57
7.52
7.66
7.89
"""
temp2 = """
7.84
7.62
7.8
7.66
7.6
7.63
7.9
7.66
7.73
7.58
7.62
7.69
8.21
7.57
7.56
7.72
7.66
7.53
7.83
7.7
7.71
7.65
7.72
7.72
7.84
7.89
7.83
"""
# you can split the lines into a list, but entries are still treated like text
temp1.split()
# here we will convert into numpy arrays
x1 = np.array(temp1.split()).astype(np.float)
x1
x2 = np.array(temp2.split()).astype(np.float)
x2
# We can also plot data.
# What are the horizontal and vertical axes?
# Is this a good way to display the data?
plt.plot(x1)
plt.plot(x2)
# An alternate pesentation
plt.hist(x1, bins=30)
np.mean(x1)
np.std(x1)
np.mean(x2)
np.std(x2)
plt.hist(x2, bins=30)
plt.scatter(x1,x2)
plt.xlim()
x1.size, x2.size
mybins = np.linspace(7.4,8.5,20)
plt.hist(x1, bins=mybins, alpha=.3,label='first')
plt.hist(x2, bins=mybins, alpha=.3,label='second')
plt.legend()
plt.xlabel('time')
plt.ylabel('counts')
plt.xlim(7.3,7.8)
plt.ylim(7.3,7.8)
plt.scatter(x1,x2)
plt.axvline(x=7.5)
plt.axhline(y=7.5)
plt.Line2D([7.5, 7.5], [7.3, 7.8], linewidth=2)