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.

74 KiB

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

Week 5 Lab — Error Propagation for Engineers and Scientists

In this lab, we will study how uncertainty in measured variables affects the uncertainty of computed quantities.

We will work through three parts:

  1. Repeated measurements and uncertainty estimation
  2. Propagation of uncertainty for one variable
  3. Propagation of uncertainty for several variables

At the end of the lab, you should be able to:

  • compute the mean and sample standard deviation from repeated measurements,
  • report a measurement with uncertainty,
  • propagate uncertainty through simple formulas,
  • identify which measured variable contributes most to the final uncertainty.

Part A — Repeated Measurements

In real experiments, the same quantity is often measured several times.
These repeated measurements help us estimate:

  • a representative value of the quantity, using the sample mean,
  • the variability of the measurements, using the sample standard deviation.

We begin with a small set of repeated voltage measurements.

Repeated voltage measurements

The following values represent repeated measurements of the same voltage.

In [2]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

V_samples = np.array([4.98, 5.01, 5.00, 5.03, 4.99, 5.02, 4.97, 5.01])

V_samples
Out[2]:
array([4.98, 5.01, 5.  , 5.03, 4.99, 5.02, 4.97, 5.01])

Compute the mean and sample standard deviation

We will use:

$$\bar{x} = \frac{1}{n}\sum_{i=1}^n x_i$$

and

$$ s = \sqrt{\frac{1}{n-1}\sum_{i=1}^n (x_i-\bar{x})^2} $$

The mean gives a central value, while the sample standard deviation describes the spread of the repeated measurements.

In [ ]:
V_mean = np.mean(V_samples)
V_std = np.std(V_samples, ddof=1)

print(f"Mean voltage = {V_mean:.4f} V")
print(f"Sample standard deviation = {V_std:.4f} V")
Mean voltage = 5.0013 V
Sample standard deviation = 0.0203 V

Report the measurement

A basic engineering report format is:

$$ V \approx \bar{V} \pm s_V $$

This is a practical summary of the measured value and its variability.

In [6]:
print(f"Reported measurement: V = {V_mean:.4f} +/- {V_std:.4f} V")
Reported measurement: V = 5.0013 +/- 0.0203 V
In [8]:
# Table
df_voltage = pd.DataFrame({
    "trial": np.arange(1, len(V_samples) + 1),
    "voltage_V": V_samples
})

df_voltage
Out[8]:
trial voltage_V
0 1 4.98
1 2 5.01
2 3 5.00
3 4 5.03
4 5 4.99
5 6 5.02
6 7 4.97
7 8 5.01
In [11]:
plt.figure(figsize=(8, 4))
plt.plot(df_voltage["trial"], df_voltage["voltage_V"], marker="o", linestyle="none", label="samples")
plt.axhline(V_mean, linestyle="--", linewidth=2, label=f"mean = {V_mean:.4f} V")
plt.xlabel("Trial")
plt.ylabel("Voltage [V]")
plt.title("Repeated Voltage Measurements")
plt.legend()
plt.grid(True, alpha=0.3)
plt.show()

# Plot the repeated measurements
#The dashed line shows the sample mean.  
#This helps us visualize the spread of the measurements around the central value.
No description has been provided for this image

Exercise A

Using the measurements above, answer the following:

  1. What is the estimated voltage?
  2. What does the sample standard deviation tell us?
  3. Are the measurements relatively precise or widely scattered?

Write a short interpretation in your own words.

Part B — Propagation of Uncertainty for One Variable

Now we consider a quantity that is not measured directly, but computed from another measured variable.

Suppose the output quantity is:

$$ A = \pi r^2 $$

If the radius (r) has uncertainty, then the area (A) also has uncertainty.

For one variable, we use the first-order propagation formula:

$$ \sigma_A \approx \left|\frac{dA}{dr}\right| \sigma_r $$

Example: Area of a circle

Let:

  • $r = 10.0$ mm
  • $\sigma_r = 0.2$ mm

Then:

$$ A = \pi r^2 $$

and

$$ \frac{dA}{dr} = 2\pi r $$

So the propagated uncertainty is:

$$ \sigma_A \approx |2\pi r| \sigma_r $$

In [ ]:
r = 10.0
sigma_r = 0.2

A = np.pi * r**2
sigma_A = abs(2 * np.pi * r) * sigma_r

print(f"Radius: r = {r:.3f} ± {sigma_r:.3f} mm")
print(f"Area:   A = {A:.3f} ± {sigma_A:.3f} mm^2")
Radius: r = 10.000 ± 0.200 mm
Area:   A = 314.159 ± 12.566 mm^2

Observe how the output uncertainty changes

We now vary the uncertainty in the radius and observe how the area uncertainty changes.

This helps us see that larger uncertainty in the input produces larger uncertainty in the output.

In [13]:
sigma_r_values = np.linspace(0.01, 0.5, 100)
sigma_A_values = abs(2 * np.pi * r) * sigma_r_values

plt.figure(figsize=(8, 4))
plt.plot(sigma_r_values, sigma_A_values)
plt.xlabel("Uncertainty in radius, sigma_r [mm]")
plt.ylabel("Uncertainty in area, sigma_A [mm^2]")
plt.title("Propagation of Uncertainty: A = pi r^2")
plt.grid(True, alpha=0.3)
plt.show()
No description has been provided for this image

Exercise B

Answer the following:

  1. If the uncertainty in radius doubles, what happens to the uncertainty in area?
  2. Why does the derivative appear in the propagation formula?
  3. For this example, is the relation between (\sigma_r) and (\sigma_A) linear?

Write a brief explanation.

</html>