You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 KiB

None <html lang="en"> <head> </head>

Part A - Repeated measurements

  • a representative value, using the samples mean
  • the measurements variability, using the sample standard deviation
In [2]:
import numpy as np 
import pandas as pd
import matplotlib.pyplot as plt

vSamples = np.array([4.98, 5.01, 5.00, 5.03, 4.99, 5.02, 4.97, 5.01])
vSamples
Out[2]:
array([4.98, 5.01, 5.  , 5.03, 4.99, 5.02, 4.97, 5.01])
In [11]:
vMean = vSamples.mean() # np.mean(vSample)
vSTD = vSamples.std(ddof=1) #sample standar deviation

print(f"Mean voltage is = {vMean:.4f} V")
print(f"Sample standard deviation is = {vSTD:.4f} V")
Mean voltage is = 5.0013 V
Sample standard deviation is = 0.0203 V
In [26]:
plt.figure(figsize=(8,4))
plt.plot(vSamples, 'ok', label="Samples")
plt.axhline(vMean, linestyle="--", linewidth=2, label=f"Mean = {vMean:.4f}")
plt.xlabel("Measurements")
plt.ylabel("Voltage [V]")
plt.ylim([4.9,5.1])
plt.grid(alpha=0.3)
plt.legend()
plt.show()
No description has been provided for this image
  1. What is the estimated voltage?
  2. What does the sample standard deviation tell us?
  3. Are the measurements relatively precise or widely scattered?

Part B - Propagation of uncertainty of one variable

Example area of a cricle

In [32]:
r = 10.0
sigmar = 0.2
Area = np.pi*r**2
sigmaA = sigmar*(2*np.pi*r)

print(f"Radius: r = {r:.4f} +/- {sigmar:.4f} mm")
print(f"Area: A = {Area:.4f} +/- {sigmaA:.4f} mm^2")
Radius: r = 10.0000 +/- 0.2000 mm
Area: A = 314.1593 +/- 12.5664 mm^2
In [46]:
sigmarValues = np.linspace(0.01, 0.5, 10)
sigmaAValues = (np.pi*2*r)*sigmarValues

plt.figure(figsize=(6,4))
plt.plot(sigmarValues, sigmaAValues, 'ok')
plt.title("Propagation of uncertainty")
plt.xlabel("Uncertainty in radius [mm]")
plt.ylabel("Uncertainty in area [mm^2]")
plt.grid(alpha=0.3)
plt.savefig("uncertainty.png", dpi=300, bbox_inches="tight")
plt.show()
No description has been provided for this image

Part c - Propagation of uncertainty for several variables

Example: Resistance from voltage and current.

  • $V=12.0 \pm 0.2$
  • $I=2.0 \pm 0.05$
In [48]:
V = 12.0
sigmaV = 0.2
I = 2.0 
sigmaI = 0.05

R = V/I
sigmaR = np.sqrt((sigmaV/I)**2 + (sigmaI*V/I**2)**2)
print(f"Resistance: R = {R:.4f} +/- {sigmaR:.4f} ohms")
Resistance: R = 6.0000 +/- 0.1803 ohms
In [49]:
termV = (sigmaV / I)**2
termI = ((V * sigmaI) / (I**2))**2
total = termV + termI

percent_V = 100 * termV / total
percent_I = 100 * termI / total

print(f"Contribution from voltage uncertainty: {percent_V:.4f}%")
print(f"Contribution from current uncertainty: {percent_I:.4f}%")
Contribution from voltage uncertainty: 30.7692%
Contribution from current uncertainty: 69.2308%
</html>