Will Barkoff and Thien Vo
import numpy as np
import math
from IPython.display import HTML, display
import tabulate
First, let's define functions to calculate the standard deviation, the $t'$ value, and the standard uncertianty of the mean
def standard_deviation(data):
N = len(data)
return np.sqrt(np.sum((data - np.mean(data))**2)/(N-1))
def t_prime(A, dA, B, dB):
return abs(A - B) / np.sqrt(dA**2 + dB**2)
def stand_unc_of_mean(data):
N = len(data)
return standard_deviation(data) / np.sqrt(N)
Now, let's add the initial data, collected using a string as the pendulum:
string10 = np.array([1.09, 1.00, 0.90])
string20 = np.array([1.07, 1.10, 1.05])
string40 = np.array([1.10, 1.21, 1.13])
And let's add the data collected using a band as the pendulum:
band10 = np.array([1.33, 1.30, 1.30])
band20 = np.array([1.30, 1.33, 1.29])
band40 = np.array([1.30, 1.34, 1.32])
Next, let's calculate the standard uncertanties of the means for each:
string10_unc = stand_unc_of_mean(string10)
string20_unc = stand_unc_of_mean(string20)
string40_unc = stand_unc_of_mean(string40)
band10_unc = stand_unc_of_mean(band10)
band20_unc = stand_unc_of_mean(band20)
band40_unc = stand_unc_of_mean(band40)
unc_of_means = [
["", "10º", "20º", "40"],
["string", string10_unc, string20_unc, string40_unc],
["band", band10_unc, band20_unc, band40_unc]
]
display(HTML(tabulate.tabulate(unc_of_means, tablefmt='html')))
| 10º | 20º | 40 | |
| string | 0.054873592110514444 | 0.014529663145135593 | 0.0328295 |
| band | 0.010000000000000009 | 0.012018504251546642 | 0.011547 |
Finally, let's calculate the distinguisabilities ($t'$ values) between the string and the band for each datapoint
distinguisabilities = [
["10º", t_prime(np.mean(band10), band10_unc, np.mean(string10), string10_unc)],
["20º", t_prime(np.mean(band20), band20_unc, np.mean(string20), string20_unc)],
["40º", t_prime(np.mean(band40), band40_unc, np.mean(string40), string40_unc)],
]
display(HTML(tabulate.tabulate(distinguisabilities, tablefmt='html')))
| 10º | 5.61757 |
| 20º | 12.3744 |
| 40º | 4.9807 |